代码之家  ›  专栏  ›  技术社区  ›  khateeb

React Native app首先显示白色屏幕,然后转到app

  •  0
  • khateeb  · 技术社区  · 7 年前

    public class MainApplication extends Application implements ReactApplication {
    
      private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
        @Override
        public boolean getUseDeveloperSupport() {
          return BuildConfig.DEBUG;
        }
    
        @Override
        protected List<ReactPackage> getPackages() {
          return Arrays.<ReactPackage>asList(
              new MainReactPackage(),
              new BlurViewPackage(),
              new OrientationPackage(),
              new ReactVideoPackage(),
              new RNDeviceInfo(),
              new LinearGradientPackage()
          );
        }
    
        @Override
        protected String getJSMainModuleName() {
          return "index";
        }
      };
    
      @Override
      public ReactNativeHost getReactNativeHost() {
        return mReactNativeHost;
      }
    
      @Override
      public void onCreate() {
        super.onCreate();
        SoLoader.init(this, /* native exopackage */ false);
      }
    }
    

    public class MainActivity extends ReactActivity {
    
        /**
         * Returns the name of the main component registered from JavaScript.
         * This is used to schedule rendering of the component.
         */
        @Override
        protected String getMainComponentName() {
            return "CONtv";
        }
    
        @Override
          public void onConfigurationChanged(Configuration newConfig) {
            super.onConfigurationChanged(newConfig);
            Intent intent = new Intent("onConfigurationChanged");
            intent.putExtra("newConfig", newConfig);
            this.sendBroadcast(intent);
        }
    }
    

    index.js

    import {AppRegistry} from 'react-native';
    import App from './src/App';
    import {name as appName} from './app.json';
    AppRegistry.registerComponent(appName, () => App);
    

    如何使白色屏幕不出现?这是在安卓系统上发生的。

    1 回复  |  直到 7 年前