Reputation: 31
We are using PhoneGap/Cordova 2.4. We are having trouble turning off the auto-hide for the splash screen on the Android side. My expectation was that that splash screen would not be hidden until there was an explictit call to navigator.splashscreen.hide(). However for our app, the splash screen is being hidden much sooner. This shows the user with an HTML page that isn't ready to be interacted with.
Per the Cordova docs, we have updated our Java code to look like this
import android.os.Bundle;
import org.apache.cordova.*;
public class MyApp extends DroidGap
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl(Config.getStartUrl(), 5000);
}
}
In this Javascript code, we have this at end of the setup method. However, as I mentioned, the splash screen is hidden much earlier. Also, when we take this line out, the splash screen is still hidden. This is the code:
// tons of setup code ...
Backbone.history.start()
Backbone.trigger('app:ready')
navigator.splashscreen.hide()
We also added these 2 options to the www/config.xml. I should note that the AutoHideSplashScreen works on the iOs app but seems to have no effect for the android app. The other option I found from an example as I have furiously searching the internet for a solution to this problem for the past few days.
<preference name="AutoHideSplashScreen" value="false" />
<preference name="auto-hide-splash-screen" value="false" />
Any help would be great.
Thanks in advance,
Kevin
Upvotes: 3
Views: 4450
Reputation: 1
Call must be made after deviceready
.run(function($ionicPlatform, $cordovaSplashscreen) {
$ionicPlatform.ready(function() {
$cordovaSplashscreen.hide();
})
});
At least this works for me. Hope it works for you guys too.
Upvotes: 0
Reputation: 4799
You can just add
<preference name="SplashScreenDelay" value="100000" />
to your config.xml then later just remove it programatically as you've done when you want.
Upvotes: 2
Reputation: 11620
Just set a really large number for the splash screen display time. E.g. instead of
super.loadUrl(Config.getStartUrl(), 5000);
do:
super.loadUrl(Config.getStartUrl(), 60000); // 60 seconds
It really doesn't matter what value you put here, as long as it's large enough that when your Javascript/CSS/HTML is fully loaded, the timeout hasn't occurred yet.
Upvotes: 2