Android splash screen won't disappear

351 views
Skip to first unread message

pamela

unread,
Oct 7, 2011, 2:15:49 PM10/7/11
to phonegap
Hey there -

I'm using normal PhoneGap (not build) and am trying to get a splash
screen working. I've read various posts and looked at sample code in
the repo, and there seem to be slight differences in the code for it.
I've commented the variable parts below.

public void onCreate(Bundle savedInstanceState)
{

super.onCreate(savedInstanceState);
super.setStringProperty("loadingDialog", "Loading..."); //
Needed?
super.init(); // Needed?

super.setIntegerProperty("splashscreen",
R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html",
1000); // Interval needed?
}

I've tried the various permutations of this code, but I always have
the same issue: the splash screen does not go away (even after the
interval, and after the phonegap reports it received the resume
event.). I'm using a 9patch image, if that matters, and I'm on an N1.

Has anyone had that issue? And what's the correct permutation of the
onCreate function?

Thanks!
- pamela

ericburnley

unread,
Oct 7, 2011, 2:52:02 PM10/7/11
to phonegap
Not sure these would apply to your case, but in case you've not seen
these:
https://github.com/phonegap/phonegap-android/issues/126
http://stackoverflow.com/questions/3904852/android-layout-broken-with-9-patch-background

I use a super simple approach w/ just a png (see below). The first
two lines you have marked as // Needed? I don't even have, and it
works fine.
This might be a stupid question, but- you do have a file named
index.html in the assets/www folder for it to navigate to, right?


public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html", 2000);
}

Bryce Curtis

unread,
Oct 7, 2011, 4:47:27 PM10/7/11
to phon...@googlegroups.com
Pamela,

loadingDialog is used to show the spinner while index.html is loading.  It's optional.

If you don't call super.appView.xxx(), then you don't need super.init().  It is automatically called by loadUrl(), if it hasn't already been called.

The interval in super.loadUrl(url, interval) is used to delay loading so that your splash screen for that amount of time.  If it's not included, then your splash screen will display, then quickly after that your index.html will display.

splashscreen identifies the file under res/drawable to display.  For your example, there needs to be a res/drawable/splash.jpg or res/drawable/splash.png.  If it's not showing, then either the file is missing or there is a problem with the format of the file.

ericburnley

unread,
Oct 7, 2011, 5:09:59 PM10/7/11
to phonegap
It sounded to me like the image showed, and didn't go away - is that
right Pamela?

Bryce Curtis

unread,
Oct 7, 2011, 6:01:49 PM10/7/11
to phon...@googlegroups.com
If the splash screen doesn't go away, then there's a problem with your index.html.  Either it's missing as @ericburnley mentioned, or there are errors with it.  Look at the Android log using "adb logcat" for any errors.

pamela fox

unread,
Oct 7, 2011, 7:23:45 PM10/7/11
to phon...@googlegroups.com
Thanks for your help.

Updates on my side:

- I removed init() and loading dialog with the same results. The
screen doesn't go away, but the html loads (as evidenced by logging
the "resume" event).

- When I don't specify a splash screen, the html loads as expected.

Since it didn't seem like the HTML was the problem, I tried replacing
the 9-patch file (splash.9.png) with a normal PNG - and it worked.
Then I renamed the splash.9.png to splash.png - and it worked (though
it was stretched).

So it seems like it's related to using a 9-patch image and it treating
it as a 9-patch image. Maybe same or related to
https://github.com/phonegap/phonegap-android/issues/126

I'll just use a non-9patch image for now.

> --
> You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/phonegap?hl=en?hl=en
>
> For more info on PhoneGap or to download the code go to www.phonegap.com
>

Christos

unread,
Dec 2, 2011, 7:49:07 AM12/2/11
to phonegap
Confirmed. I have the same problem with a 9-patch image and phonegap
1.2.0. The splash screen appears, then one side of it resizes down and
I can see part of the loaded html behind it.

On Oct 7, 11:23 pm, pamela fox <pamela....@gmail.com> wrote:
> Thanks for your help.
>
> Updates on my side:
>
> - I removed init() and loading dialog with the same results. The
> screen doesn't go away, but the html loads (as evidenced by logging
> the "resume" event).
>
> - When I don't specify a splash screen, the html loads as expected.
>
> Since it didn't seem like the HTML was the problem, I tried replacing
> the 9-patch file (splash.9.png) with a normal PNG - and it worked.
> Then I renamed the splash.9.png to splash.png - and it worked (though
> it was stretched).
>
> So it seems like it's related to using a 9-patch image and it treating

> it as a 9-patch image. Maybe same or related tohttps://github.com/phonegap/phonegap-android/issues/126

sebotron

unread,
Dec 8, 2011, 9:12:09 PM12/8/11
to phonegap
I would like to confirm this as well. Using PG 1.2.0 with a 9-patch
splashscreen. I get a very similar behavior as Christos. Splashscreen
appears fine, then an area about a quarter of the screen clears in the
top left and I can see the loaded html inside it.

Changing orientation of the device while this happens doesn't cause a
resize of the cleared area, but it does reposition itself to the top
left corner.

imaima

unread,
Dec 11, 2011, 9:02:37 PM12/11/11
to phonegap
I have the same problem.
Here are my solution for these.
After you made 9-patch image using upper/left 1pixel line, fill right/
bottom 1 pixel line using black pixel.
I hope this will solve the problem.
Reply all
Reply to author
Forward
0 new messages