react-native-make
react-native-make copied to clipboard
SplashScreen not hiding in Android
Hi, I haven't complete the iOS one, but I hope my Android case helps you. I will try to update this comment after I complete the iOS one.
For my case (RN 0.61) in Android, it seems like the library messes up my MainActivity.java so I just discard the changes made to it and it worked.
The the library adds:
import android.os.Bundle;
import org.devio.rn.splashscreen.SplashScreen;
...
@Override
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.show(this, R.style.SplashScreenTheme); anything_that_exists_here();
super.onCreate(savedInstanceState);
SplashScreen.show(this, R.style.SplashScreenTheme); }
to the android/app/src/main/java/com/project_name/MainActivity.java
-
import android.os.Bundleandimport org.devio.rn.splashscreen.SplashScreenare already there for my case, but since they are not the 1st and 2nd imports, the library forcefully adding the imports made it double imports. This is not the reason it didn't work though. -
The real culprit is that
SplashScreen.show(this, R.style.SplashScreenTheme);is added after theanything_you_had_here(); \n super.onCreate(savedInstanceState);. So yeah, there is a bug in this library that the line adding is messed up.
I don't have the time to do a PR for the moment but I hope this helps @yleflour track down the bug both on the Android and iOS (if present) side and fix it. Good luck guys!
=== For completeness, you just need:
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.show(this, R.style.SplashScreenTheme);
super.onCreate(savedInstanceState);
}
Once you do this, then the library will detect SplashScreen.show(this, R.style.SplashScreenTheme); successfully next time so you won't ever have to manually do this again.
@Riseley You need to explicitly call SplashScreen.hide() in your code
It is fully explained here:
https://github.com/bamlab/react-native-make/blob/master/docs/set-splash.md#prerequisites
@adibas03 i already call SplashScreen.hid() but Not hiding in Android
@Override
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.show(this, R.style.SplashScreenTheme); <<<
SplashScreen.show(this, true); // here
super.onCreate(savedInstanceState);
SplashScreen.show(this, R.style.SplashScreenTheme); <<<
}
In the code above, two additional lines are generated.
so i edit
=== For completeness, you just need:
protected void onCreate(Bundle savedInstanceState) { SplashScreen.show(this, R.style.SplashScreenTheme); super.onCreate(savedInstanceState); }Once you do this, then the library will detect SplashScreen.show(this, R.style.SplashScreenTheme); successfully next time so you won't ever have to manually do this again.