Custom splash screen duration android

1,014 views
Skip to first unread message

amrit

unread,
Dec 20, 2012, 10:08:52 PM12/20/12
to phon...@googlegroups.com
So I've searched for this around the net, and haven't found a solution that works. Right now I have my splash screen set up like this. 

public class hc_app extends DroidGap
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        super.setIntegerProperty("splashscreen", R.drawable.splash);
        super.loadUrl("file:///android_asset/www/views/index.html",15000);
     }
}

No matter what number I put in super.loadUrl("file:///android_asset/www/views/index.html",15000); it only stays up for a few seconds until the js is loaded I guess, and then it proceeds to my index.html. Now I want the splash screen to stay up indefinitely, so I can hide it when I choose with

navigator.splashscreen.hide();
But i can't get it to stay up. Is there a hidden setting which disables the splash screen from going away when the app is fully loaded?

Simon MacDonald

unread,
Dec 21, 2012, 12:17:09 PM12/21/12
to phonegap
It should stay in view for 15 seconds. What version of PhoneGap are you using?

Simon Mac Donald
http://hi.im/simonmacdonald
> --
> -- 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
>
> To compile in the cloud, check out build.phonegap.com
>
>

amrit

unread,
Dec 21, 2012, 2:34:18 PM12/21/12
to phon...@googlegroups.com
Hey Simon,

I know it should stay for longer, but it doesn't! I'm using cordova 2.2 testing on android 4.1.2

Simon MacDonald

unread,
Dec 21, 2012, 2:49:43 PM12/21/12
to phonegap
Well, I just tried to reproduce it and I can't. Looking at the HC app
I see the splash screen for about 3 seconds then a black screen then
the login page. Is that what you are seeing too?

Not sure what would be causing your issue.

Simon Mac Donald
http://hi.im/simonmacdonald


amrit

unread,
Dec 21, 2012, 3:42:41 PM12/21/12
to phon...@googlegroups.com
The file on the play store is actually quite old, I believe I had 3000 delay on that one. Here is my latest apk with the 15000 delay

Simon MacDonald

unread,
Dec 21, 2012, 3:49:26 PM12/21/12
to phonegap
I installed this apk on my emulator and showed the splash screen for 15 seconds.

amrit

unread,
Dec 21, 2012, 4:12:39 PM12/21/12
to phon...@googlegroups.com
I just installed that exact APK on a Motorola Atrix HD running 4.1.2, Sony Walkman 2.3.7, Samsung Galaxy S3 4.1.1 and on all three it only lasted a couple seconds. Maybe it only lasts 15 sec on an emulator? I normally don't use the android emulators since they are incredibly slow compared to the iOS one, but I will try now.

Tried it on the emulator, can't tell if it is actually 15 seconds, or the emulator is just that slow. 

amrit

unread,
Dec 21, 2012, 6:52:54 PM12/21/12
to phon...@googlegroups.com
Any insights Simon as to why it works on an emulator and not an actual device? I was planning on updating my app in the play store tonight. Any help would be greatly appreciated!!


I'm planning on updating my app 

Amrit Kahlon

unread,
Dec 22, 2012, 12:25:20 AM12/22/12
to phon...@googlegroups.com
False alarm, it only seems to do that sometimes, very strange. 

On Friday, December 21, 2012 9:19:39 PM UTC-8, Amrit Kahlon wrote:
Alright I think I found something. When I install from eclipse via USB and using my debug keystore, the splash screen only lasts a few seconds. However when I export the app using another keystore and install it ota, the splash screen lasts the correct amount of time! Testing it further now. 

Simon MacDonald

unread,
Dec 22, 2012, 9:55:25 AM12/22/12
to phonegap
Sorry Amrit, I can't tell why the splash screen disappears for you so quickly. I'd have to see what you are actually doing in the app in order to help.




amrit

unread,
Dec 28, 2012, 2:34:21 PM12/28/12
to phon...@googlegroups.com
Alright, so I made a fresh cordova app and the custom splash screen length works perfectly. There must be something wrong with my code. Here is my main activity java file, is there something here that is preventing it?

/*

       Licensed to the Apache Software Foundation (ASF) under one

       or more contributor license agreements.  See the NOTICE file

       distributed with this work for additional information

       regarding copyright ownership.  The ASF licenses this file

       to you under the Apache License, Version 2.0 (the

       "License"); you may not use this file except in compliance

       with the License.  You may obtain a copy of the License at


         http://www.apache.org/licenses/LICENSE-2.0


       Unless required by applicable law or agreed to in writing,

       software distributed under the License is distributed on an

       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

       KIND, either express or implied.  See the License for the

       specific language governing permissions and limitations

       under the License.

 */

package com.hockeycommunity.hc_app;

import android.content.pm.ActivityInfo;

import android.os.Bundle;

import android.util.DisplayMetrics;


import org.apache.cordova.*;


public class hc_app extends DroidGap

{

    @Override

    public void onCreate(Bundle savedInstanceState)

    {

        super.onCreate(savedInstanceState);


        DisplayMetrics dm = new DisplayMetrics();

        getWindowManager().getDefaultDisplay().getMetrics(dm);

        int width = dm.widthPixels; //720

        int height = dm.heightPixels; //1280

        if(width > 770){

             if(width > height){

                    super.setIntegerProperty("splashscreen", R.drawable.ltsplash); // Landscape tablet

                

        } else {

                super.setIntegerProperty("splashscreen", R.drawable.ptsplash); // Portrait tablet

             }

        } else {

            super.setIntegerProperty("splashscreen", R.drawable.splash); // Regular splash

            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Lock orientation phone

        }

                

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

    }

}

Simon MacDonald

unread,
Dec 30, 2012, 11:04:23 AM12/30/12
to phonegap
Nothing jumps out at me in this code. In your html do you call navigator.splashscreen.hide() at any point?

Amrit Kahlon

unread,
Jan 2, 2013, 3:55:02 PM1/2/13
to phon...@googlegroups.com
No I do not, but I did find out that the problem lies somewhere in my onDeviceReady function. I commented it out, and the splash screen stayed for the proper duration. I will mess around with it and find out where the problem lies. Thanks for your help Simon, as usual your responses were quick and informative.

Simon MacDonald

unread,
Jan 2, 2013, 3:59:35 PM1/2/13
to phonegap
Cool, glad you figured it out. When I get back to Ottawa I'm going to use Hockey Community more. Come summer I expect the goalie finder feature to get a workout.




Reply all
Reply to author
Forward
0 new messages