2

I found in this answer this code:

super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html",5000);

And it works, but like this, result is:

  • Splash screen for 5 seconds

  • Black screen until the app is ready

  • index.html when app is ready

So I was wondering if there is any chance of running this

super.loadUrl("file:///android_asset/www/index.html");

As a callback of some ready function, is there a way?

-EDIT-

Changing it to 10 seconds doesn't show me the black screen but I would like to show index.html the exact same moment that the app is ready (not sooner, not much later :D)

Community
  • 1
  • 1
Toni Michel Caubet
  • 19,333
  • 56
  • 202
  • 378

4 Answers4

1
        // Show LOGO ,start to  MainActivity that watting for some seconds
        new Handler().postDelayed(new Runnable() {
            public void run() {
                /*
                 * Create an Intent that will start the Main WordPress
                 * Activity.
                 */
                //
                RedirectMainActivity();
            }
        }, 4000);
RZMars
  • 125
  • 8
0

Android does not provide any of native API to deal with Splash Screen but you can use Handler to show fake splash screen.

  //load the splash screen
  super.loadUrl("file:///android_asset/www/someSplashScreen.html");
  new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
                    // splash screen successfully timeout
                    //start new activity or load html layout
                     super.loadUrl("file:///android_asset/www/index.html");

        }
    }, 4000);//timeout after 4 sec
Shushant
  • 1,625
  • 1
  • 13
  • 23
  • Just one question, why the 4 seconds delay? the thing is that i want no extra delay at all, i just want to use the splashcreen as a 'loading' image:), if I put 0 there will that achieve it? thanks! – Toni Michel Caubet Sep 09 '13 at 19:54
  • i have taken 4000ms just for example you can take whatever value you want to. – Shushant Sep 10 '13 at 06:51
  • if you don't want to do background stuff then 200-800 ms will be enough and in case of 0ms i think no splash screen will be shown. – Shushant Sep 10 '13 at 06:57
  • i just want to replace the black screen that is shown until the app is ready with the splashcreen... – Toni Michel Caubet Sep 10 '13 at 07:45
  • I dont have any idea about it. You will need to make your application responsive. – Shushant Sep 10 '13 at 10:58
0

Have you alredy tried this?

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;



     public class Splash extends Activity {

            private final int SPLASH_DISPLAY_LENGHT = 1000;

            /** Called when the activity is first created. */
            @Override
            public void onCreate(Bundle icicle) {
                super.onCreate(icicle);
                setContentView(R.layout.splashscreen);

                /* New Handler to start the Menu-Activity 
                 * and close this Splash-Screen after some seconds.*/
                new Handler().postDelayed(new Runnable(){
                    @Override
                    public void run() {
                        /* Create an Intent that will start the Menu-Activity. */
                        Intent mainIntent = new Intent(Splash.this,Menu.class);
                        Splash.this.startActivity(mainIntent);
                        Splash.this.finish();
                    }
                }, SPLASH_DISPLAY_LENGHT);
            }
        }
user2606414
  • 718
  • 2
  • 7
  • 13
0

In your link to a previous question there is a further link to a Blog

It claims, that with version 1.8.0 of PhoneGap you can call navigator.splashscreen.hide();

Check the Blog (read thru all of it as it is a bit missleading on the first two paragraphs).

jboi
  • 11,324
  • 4
  • 36
  • 43