質問

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

役に立ちましたか?

解決

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

他のヒント

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top