react-native-splash-screen icon indicating copy to clipboard operation
react-native-splash-screen copied to clipboard

MainActivity

Open ijry opened this issue 7 years ago • 7 comments

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

ijry avatar May 09 '18 09:05 ijry

@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);
    }

    ...

AwoyoToyin avatar May 10 '18 07:05 AwoyoToyin

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

bhrg3se avatar May 21 '18 04:05 bhrg3se

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

rendomnet avatar May 28 '18 08:05 rendomnet

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";
    }
}

vvavdiya avatar Jun 01 '18 07:06 vvavdiya

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

cayasso avatar Jun 21 '18 17:06 cayasso

that should be on the readme

radjivF avatar Sep 22 '21 04:09 radjivF

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

nitin-kumar-bs avatar May 06 '24 08:05 nitin-kumar-bs