phonegap 3.1 - Unable to hide splash screen on device ready

后端 未结 6 507
北荒
北荒 2020-12-10 16:15

Using phonegap 3.1 I\'m trying to hide the splash screen when device is ready:

document.addEventListener(\"deviceready\", onDeviceReady, false);

function on         


        
相关标签:
6条回答
  • 2020-12-10 16:38

    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.

    0 讨论(0)
  • 2020-12-10 16:49

    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:

    • splash screen plugin and configuration
    • adding the cordova.js and cordova_plugins.js to index.html. This is not necessary anymore since many versions ago - the build does it for you.
    • in the platforms/android/assets/www folder there were cordova.js and cordova_plugins.jsfiles present
    • in the config.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.

    0 讨论(0)
  • 2020-12-10 16:57

    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.

    0 讨论(0)
  • 2020-12-10 16:59

    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).

    0 讨论(0)
  • 2020-12-10 17:04

    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>
    
    0 讨论(0)
  • 2020-12-10 17:05

    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.

    0 讨论(0)
提交回复
热议问题