3

I am using react-native-navigation v2 in my project, when i follow the step 6 of initial setup of react-native-navigation v2

then following changes are done by me in 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

 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?

GAURAV
  • 647
  • 6
  • 18

1 Answers1

0

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);
    }
}
Alale sa
  • 147
  • 2
  • 9
  • 1
    Please include an explanation of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. – Android Aug 06 '19 at 09:25