Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Remove White Screen after Splash Screen in React Native For Android

I have a default react native project I installed from this turorial and I added a splash screen to my Project with this tutorial. However, now I get:

  • a 0.5 secend splash screen photo
  • then 1.5 secend white screen
  • and after that my app started,

What is the best and most standard way to fix this problem? I need my splash screen for 1 secend and after that my app should start, I have read more articles but I couldn't find a fix for react native.

<application
  android:name=".MainApplication"
  android:allowBackup="true"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:theme="@style/AppTheme">
  <activity
    android:name=".SplashActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:windowSoftInputMode="adjustResize"
    android:theme="@style/SplashTheme">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
  <activity android:name=".MainActivity" />
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>

like image 464
Saeed Heidarizarei Avatar asked Jun 06 '17 08:06

Saeed Heidarizarei


People also ask

How do I get rid of the white screen on my Android?

One of the reliable ways to fix the white screen of death on Android Phones or Tablets is to reboot your phone. First, press down the Power Button and Volume Down together, then tap on reboot. Once your phone reboot, it might result from a virus causing the Phone IOS not to load on time.

How do I change the splash screen in Android react-native?

To change this, in your android/app/src/main/res/drawable folder create an image called splash. png . Then in splash_screen. xml change @mipmap/ic_launcher to @drawable/splash .

How do you handle splash screen in react-native?

How to build a splash screen in React Native. First, head over to Appicon. Drag your image on the box provided, select 4x as your base size, select iOS and Android, and click generate. This process should take approximately two minutes to complete, depending on your internet speed.


1 Answers

I too have been through this problem. In my case it was redux persist library that use to extract persisted state from storage and feed it into the reducers and this process use to take almost 1 second during that second it used to show white screen a little flicker and then it renders the actual screen.

The work around i used is this actually the control to hide splash is on javascript side you are doing this to hide it.

componentDidMount() {
    SplashScreen.hide();
}

Just add a little delay and it will work fine.

componentDidMount() {
    setTimeout(() => SplashScreen.hide() , 2000);
}
like image 52
ArkaneKhan Avatar answered Nov 02 '22 20:11

ArkaneKhan