将现有的Android 项目集成rn工程,发现模拟器不响应双击R reloadjs

解决办法如下在入口的activity中加入以下代码
手动强制让rn reloadjs

  private long lastTime = 0;
//监听键盘双击R事件
  @Override
  public boolean onKeyUp(int keyCode, KeyEvent event) {
      if (keyCode == KeyEvent.KEYCODE_MENU && mReactInstanceManager != null) {
          mReactInstanceManager.showDevOptionsDialog();
          return true;
      }

      if(keyCode==46 && BuildConfig.DEBUG){ //press R
          long currentTime = System.currentTimeMillis();
          if(currentTime- lastTime < 300){
              reloadJS();
          }
          lastTime  =System.currentTimeMillis();
      }
      Log.e(TAG, "onKeyUp() called with: keyCode = [" + keyCode + "], event = [" + event + "]");
      //log

      return super.onKeyUp(keyCode, event);
  }

//reload
private void reloadJS() {
      Log.e(TAG, "reloadJS: " );
      mReactInstanceManager.getDevSupportManager().handleReloadJS();

  }

你可能感兴趣的:(将现有的Android 项目集成rn工程,发现模拟器不响应双击R reloadjs)