Reputation: 6764
Using phonegap 3.1 I'm trying to hide the splash screen when device is ready:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
navigator.splashscreen.hide();
}
But it returns:
Cannot call method 'hide' of undefined
The navigator object doesn't including the splashscreen attribute.
I've tried it on phonegap 2.9 and it works fine.
Upvotes: 7
Views: 14494
Reputation: 21370
After upgrading to Phonegap Desktop 0.3.6, I had a similar issue and one of my older apps was stuck on the splash screen. In the configuration window, it was showing the correct app name and version and it was updating as soon as I was modifying the config.xml. In the console I had only one error: 500
for http://localhost:3000/cordova_plugins.js
A new app was working fine.
I tried all the above:
cordova.js
and cordova_plugins.js
to index.html
. This is not necessary anymore since many versions ago - the build does it for you.platforms/android/assets/www
folder there were cordova.js
and cordova_plugins.js
files presentconfig.xml
there was specified <content src="index.html" />
In the end what solved my problem was to completely delete the platforms
folder and run cordova platform add android
again. I guess it's safe to do this after each Phonegap upgrade.
Upvotes: 0
Reputation: 1200
Add this:
<preference name="SplashScreen" value="splash.png" />
<preference name="SplashScreenDelay" value="3000" />
The navigator.splashscreen.hide() doesn't work for me either.
UPDATE: navigator.splashscreen.hide() only works when building online (phonegap build).
Upvotes: 0
Reputation: 6764
After research and experiments this is what we had to do in order to get it work:
cordova plugin add org.apache.cordova.splashscreen
cordova build
Then, cordova build was adding the wrong lines to the config.xml - So we had to change it to the following:
<feature name="SplashScreen">
<param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
</feature>
And in your main activity
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.setIntegerProperty("splashScreenDelay", 10000); //time to display the splash
Finally we have been able to use hide
method from javascript.
Upvotes: 9
Reputation: 356
If you're using phonegap build, rather than doing
cordova plugin add ...
from the command line, you'll need to add the plugin and feature to the config.xml
:
<gap:plugin name="org.apache.cordova.splashscreen" />
<feature name="SplashScreen">
<param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
<param name="ios-package" value="CDVSplashScreen" />
</feature>
Upvotes: 1
Reputation: 5376
Are you using the CLI to add the SplashScreen plugin? You have to add the plugin with $ cordova plugin add org.apache.cordova.splashscreen
(copy the plugin code from plugins.cordova.io into /yourApp/plugins/org.apache.cordova.splashscreen/ and then later cordova build
to copy the plugin code into the appropriate platform location.
Upvotes: 3
Reputation: 2569
Only thing I can guess is to double check that you have <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
in the head of your HTML that is calling that JS. Sorry, haven't messed with 3.1 yet.
Upvotes: 0