[英]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.