0

I am facing an issue while trying to add a splash screenin Android.
Below is the code I used

public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    super.setIntegerProperty("splashscreen", R.drawable.splash);
    super.bindBrowser(appView);
    super.loadUrl(getWebMainFilePath(), 5000);
}

I see the splash image, but then after few minutes I get a blank screen and the app crashes.

Idan Adar
  • 44,156
  • 13
  • 50
  • 89
Surya
  • 439
  • 3
  • 9
  • 31

3 Answers3

2

When using Worklight, you can show splash screen in onWLInitCompleted method and leave onCreate method as default.
Below code test on Nexus 4, Andriod 4.2.2.

@Override
public void onWLInitCompleted(Bundle savedInstanceState) {
    // set splash screen image
    super.setIntegerProperty("splashscreen", R.drawable.logo_image);
    // Set skin name to skip load skinLoader.html if you have no customized skin.
    // This will fix the splash screen flicker on some Android devices when the App first time running.
    WLUtils.writeWLPref(getContext(), "wlSkinName", "default");
    WLUtils.writeWLPref(getContext(), "exitOnSkinLoader", "true");
    // show splash screen 3 seconds
    super.loadUrl(getWebMainFilePath(), 3000);
}
Eric Wang
  • 109
  • 4
0

I dont know will it help you or not but just try to use this code...

setContentView(R.layout.splashscreen);
    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {

        public void run() {
            // TODO Auto-generated method stub
            finish();
            Intent menu = new Intent(getBaseContext(), MainMenu.class);
            startActivity(menu);
        }
    }, 3000);

Hope it works..

AndiM
  • 2,196
  • 2
  • 21
  • 38
0

I do what you do in onCreate, but load the URL like this:

public void onWLInitCompleted(Bundle savedInstanceState){
    super.loadUrl(getWebMainFilePath(), 5000);
}

Works for me (testing on Nexus 7, Android 4.2.2).

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • I tried this ,for the first time I run the application in android it shows splash screen and then it shows html page without Jquery components/styles applied.Later I get a blank black page and then the actual html page with expected results(with all the jquery components/styles applied)...:((But then launching the app for the second time works fine – Surya Apr 16 '13 at 06:54