简体   繁体   English

如何使用react-native-navigation v2添加react-native-splash-screen

[英]How to add react-native-splash-screen with react-native-navigation v2

I am using react-native-navigation v2 in my project, when i follow the step 6 of initial setup of react-native-navigation v2 我在我的项目中使用react-native-navigation v2,当我按照react-native-navigation v2的初始设置的第6步时

then following changes are done by me in MainActivity.java 然后我在MainActivity.java中完成了以下更改

-import com.facebook.react.ReactActivity;
+import com.reactnativenavigation.NavigationActivity;

-public class MainActivity extends ReactActivity { 
+public class MainActivity extends NavigationActivity {
-    @Override
-    protected String getMainComponentName() {
-        return "yourproject";
-    }
}

when i am follow the initial setup step in react-native-splash-screen 当我按照react-native-splash-screen中的初始设置步骤进行操作时

 import android.os.Bundle; // here 
import com.facebook.react.ReactActivity;
// react-native-splash-screen >= 0.3.1 
import org.devio.rn.splashscreen.SplashScreen; // here 
// react-native-splash-screen < 0.3.1 
import com.cboy.rn.splashscreen.SplashScreen; // here 

public class MainActivity extends ReactActivity {
   @Override
    protected void onCreate(Bundle savedInstanceState) {
        SplashScreen.show(this);  // here 
        super.onCreate(savedInstanceState);
    }
    // ...other code 
}

then there is a conflict, as MainActivity is now extends NavigationActivity instead of ReactActivity , and to follow initial setup of react-native-splash-screen i need to override ReactActivity , What should i do now, to add react-native-splash-screen with react-native-navigation v2? 然后出现冲突,因为MainActivity现在扩展了 NavigationActivity而不是ReactActivity ,并且遵循react-native-splash-screen的初始设置我需要覆盖 ReactActivity ,我现在应该做什么,添加react-native-splash-screen使用react-native-navigation v2?

I had the same issue and resolved it just like this : 我有同样的问题,并解决它就像这样:

import com.reactnativenavigation.NavigationActivity;
import org.devio.rn.splashscreen.SplashScreen;
import android.os.Bundle;

public class MainActivity extends NavigationActivity {
     @Override
    protected void onCreate(Bundle savedInstanceState) {
        SplashScreen.show(this);
        super.onCreate(savedInstanceState);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在我的Windows上从克隆的repo运行React-Native-Navigation v2 Playground? - How do I run React-Native-Navigation v2 Playground from the cloned repo on my Windows? 无法解析“...”的依赖关系:无法解析项目:react-native-navigation - Unable to resolve dependency for '…': Could not resolve project :react-native-navigation 您如何在本机反应中为启动画面的传出过渡设置动画 - How do you animate the outgoing transition of a splash screen in react native 添加react-native-navigation依赖关系后,React-Native构建失败 - React-Native build faild after adding the react-native-navigation dependencies 如何在初始屏幕上锁定方向 Android Studio React Native layout.xml - How to lock orientation on splash screen Android Studio React Native layout.xml React Native 屏幕卡在加载屏幕上 - React Native screen stuck at loading screen 如何在 class 组件中使用导航? REACT-NATIVE - How can I use navigation in a class component? REACT-NATIVE 反应本机,调试本机库? - React native, Debugging a native library? 如何在更新时用原生 Android APK 替换 React Native Android APK? - How to replace React Native Android APK with a Native Android APK on update? Android Studio v 3.3在构建本机应用程序时出现错误 - Android Studio v 3.3 Giving error on building react native application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM