crazycodeboy / react-native-splash-screen

A splash screen for react-native, hide when application loaded ,it works on iOS and Android.
MIT License
5.59k stars 1.09k forks source link

MainActivity #208

Open ijry opened 6 years ago

ijry commented 6 years ago

Why My Andorid does not has a onCreate method inthe MainActivity?

AwoyoToyin commented 6 years ago

@ijry I believe you should add this yourself. Mine did not have an onCreate method either but, following the installation guide:

...
import org.devio.rn.splashscreen.SplashScreen; // import this
import android.os.Bundle; // import this

public class MainActivity extends ReactActivity {

    // I added this method myself
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        SplashScreen.show(this);
        super.onCreate(savedInstanceState);
    }

    ...
bhrg3se commented 6 years ago

I am also having this issue. I have tried adding onCreate() myself. I tried removing onNewIntent() method and keeping both but neither worked.

rendomnet commented 6 years ago

I dont have this code too. And app is not launching if I add this code.

vvavdiya commented 6 years ago

Working example of MainActivity.java

package com.myapp
import android.os.Bundle;
import com.facebook.react.ReactActivity;
import org.devio.rn.splashscreen.SplashScreen;

public class MainActivity extends ReactActivity {

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
     @Override
    protected void onCreate(Bundle savedInstanceState) {
        SplashScreen.show(this);  // here
        super.onCreate(savedInstanceState);
    }
    @Override
    protected String getMainComponentName() {
        return "myapp";
    }
}
cayasso commented 6 years ago

So the key is to add import android.os.Bundle; as shown above ;-)

radjivF commented 2 years ago

that should be on the readme

nitin-kumar-bs commented 4 months ago

when i added this code in mainActivity.java ==> @Override protected void onCreate(Bundle savedInstanceState) { SplashScreen.show(this); // here super.onCreate(savedInstanceState); } getting crash error and why it's giving crash error

12