Reputation: 431
while I was doing the setup of the library, following what's said there: https://github.com/crazycodeboy/react-native-splash-screen I found that in MainActivity.java there's no more the onCreate method.
MainActivity.java RN 0.60
package com.testApp;
import com.facebook.react.ReactActivity;
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 String getMainComponentName() {
return "testApp";
}
}
So I tried to do the setup in the getMainComponentName method: MainActivity.java
package com.testApp;
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 String getMainComponentName() {
SplashScreen.show(this);
return "testApp";
}
}
but when I try to compile it gives me this error: error: cannot find symbol variable SplashScreen
Anyone knows how to do it?
Upvotes: 1
Views: 3709
Reputation: 1023
Override the onCreate method inside the MainActivity, like this :
@Override
protected void onCreate(Bundle savedInstanceState){
SplashScreen.show(this);
super.onCreate(savedInstanceState);
}
don't forget to import android.os.Bundle
and import org.devio.rn.splashscreen.SplashScreen;
Upvotes: 6