【问题标题】:close the Android app when connection timed out连接超时时关闭 Android 应用
【发布时间】:2013-03-19 14:36:12
【问题描述】:

我正在使用 phonegap 开发移动应用程序。当服务器连接超时时,如何关闭 Android 应用程序。

我正在使用 javascript ajax XMLHttpRequest 对象。

我的代码: var xmlhttp = new XMLHttpRequest();xmlhhttp.open('POST', url, true); xmlhttp.onreadystatechange = function () {XXXXX} var xmlHttpTimeout=setTimeout(ajaxTimeout,10000);function ajaxTimeout(){navigator.app.exitApp();}

但应用程序仍然没有关闭。

问候, 毗湿奴

【问题讨论】:

    标签: ajax cordova


    【解决方案1】:

    尝试在 ajaxTimeout 函数中使用 device.app.exitApp() 而不是 navigator.app.exitApp();

    也试试这个

    将 minSdkVersion(以前设置为 8)设置为 2 AndroidManifest.xml 文件修复了我遇到的问题 navigator.app.exitApp(); Droid Incredible 上的 2.3.4 行和 2.3.3 上的模拟器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-28
      • 1970-01-01
      • 2022-01-20
      • 2014-01-11
      • 2018-04-29
      • 2012-05-23
      • 1970-01-01
      • 2015-10-24
      相关资源
      最近更新 更多