您的位置:首页 > Web前端 > React

React Native android 如果调不出开发菜单栏如何处理

2016-11-01 16:16 190 查看

使用魅族3调试,咋都加载不出“开发者菜单栏”,通过查看fackboo react的API 具体位置在react-native jar 包中的DevSupportManagerImpl类中showDevOptionsDialog(),对应的我们能扣出相应的方法重写一个开发者菜单



 

如何实例化 DevSupportManager接口,通过ReactInstanceManager:

 

mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
//.setUseOldBridge(true) // uncomment this line if your app crashes
.build();
mDevSupportManager=mReactInstanceManager.getDevSupportManager();

 

1. 与RN服务交互ReloadJS

 

mDevSupportManager.handleReloadJS();

2.设置RN服务器的host以及端口号 用DevSettingsActivity ,直接启动就好,在manifest.xml记得引用Acitivty

<activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/>

下面是代码中

Intent intent = new Intent();
intent.setClass(MainActivity.this, DevSettingsActivity.class);
startActivity(intent);


 

常用的就是这两个,其他的也可以对着源码自己写的

基本上不能热更新,第一先检查网络问题,手机在浏览器中输入 http://host:port能访问到RN Server 

 

再看Activity中设置的初始化打包路径设置对了没...react-native jar能不能正常引用到,这个可以在as中调试!
 

 

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: