简体   繁体   中英

React Native 0.60.5 react-native-splash-screen configuration android

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?

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM