Jan Leon
Jan Leon

Reputation: 176

splash screen error phonegap

Im trying to add splash screen to my app, I modify my app.java to look like

 public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        super.init();
        super.setIntegerProperty("splashscreen", R.drawable.splash);
        // Set by <content src="index.html" /> in config.xml
        super.loadUrl("file:///android_asset/www/index.html");
    }

and when I run the app I got an error saying command failed with exit code 2

I follow the instruction from here phonegap - splash screen for Android app

Upvotes: 0

Views: 391

Answers (2)

Dawson Loudon
Dawson Loudon

Reputation: 6029

The instructions you have are very outdated. You can now run:

cordova plugin add org.apache.cordova.splashscreen

Then you don't have to modify app.java

Also, make sure to have values set in config.xml:

<preference name="SplashScreen" value="splash" />
//splash is the name of the image without the extension
<preference name="SplashScreenDelay" value="20000" />
//delay is optional

Additionally, make sure that for android the image is in the /platforms/android/res/drawable folder(s).

Lastly, make sure to run cordova build or cordova run after making these changes

Documentation here

Upvotes: 1

user2647710
user2647710

Reputation: 43

Try changing the code to :

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.init(); super.setIntegerProperty("splashscreen", R.drawable.splash); // Set by in config.xml super.loadUrl("file:///android_asset/www/index.html",3000); }

Upvotes: 1

Related Questions