Restart my Phonegap app programmatically

前端 未结 3 1972
醉酒成梦
醉酒成梦 2020-12-14 14:56

How can I programmatically restart my phonegap app? I exit the app easily through navigator.app.exitApp(), but I would like it to restart immediately.

The reason I

相关标签:
3条回答
  • 2020-12-14 15:42

    I use the following:

    location.reload(); 
    

    Works a treat for me.

    Paul

    0 讨论(0)
  • 2020-12-14 15:51

    This works for iOS and Android (at least with 2016 platform versions). It works also in SPA applications.

    // keep startup url (in case your app is an SPA with html5 url routing)
    var initialHref = window.location.href;
    
    function restartApplication() {
      // Show splash screen (useful if your app takes time to load) 
      navigator.splashscreen.show();
      // Reload original app url (ie your index.html file)
      window.location = initialHref;
    }
    
    0 讨论(0)
  • 2020-12-14 15:56

    Try this

    navigator.app.loadUrl("file:///android_asset/www/index.html", {wait:2000, loadingDialog:"Wait,Loading App", loadUrlTimeoutValue: 60000});
    

    Bakri

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