Skip to content
This repository was archived by the owner on Oct 7, 2021. It is now read-only.
This repository was archived by the owner on Oct 7, 2021. It is now read-only.

SplashScreen not hiding in Android #29

Description

@RiseOoi

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

  1. import android.os.Bundle and import org.devio.rn.splashscreen.SplashScreen are 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.

  2. The real culprit is that SplashScreen.show(this, R.style.SplashScreenTheme); is added after the anything_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.

Activity

  1. adibas03 commented on Mar 16, 2020

    @adibas03
    Contributor

    @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

  2. gruming commented on Mar 26, 2020

    @gruming

    @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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions