gpt4 book ai didi

android - 回到前台时应用程序卡住(Cordova 3 + jquery mobile)

转载 作者:太空宇宙 更新时间:2023-11-03 10:21:46 24 4
gpt4 key购买 nike

我们正在使用最新的 AC (3.1.0) + jquery mobile 开发移动应用程序。该应用程序在 google play 商店 ( https://play.google.com/store/apps/details?id=com.mventix.sellPro&hl=bg ) 上可用,但我们遇到了奇怪的问题。当应用程序启动时,打开不同的 View 并做一些事情是没有问题的。但是当应用程序进入后台一段时间(只要它发生在 10 分钟到 2-3 小时之间)并且在恢复应用程序后用户界面被卡住并且没有任何响应也没有错误打印在 logcat 中。我们必须终止应用程序并重新启动它才能使其正常工作。此外,我们正在使用 WEBSQL 和 LocalStorage,我们还将一些文件存储在 app/cache/中,因为该应用程序需要在没有互联网的情况下运行。我们正在使用 cordova 中的许多插件。我在 apache cordova bugtracker 中发现了类似的错误,但它们适用于较旧的 cordova 版本。

similar bug

在这两个地方,问题看起来很相似,但据我所知,它们已在最新的 cordova 版本中修复。

此问题出现在(android 4.0.3、4.1.2、4.2.2)这些设备上,包括 LG nitro、HP slate 7 Samsung GT2 7inch samsung sIII 和 s IV。

按照这个顺序,我阅读并搜索了 phonegap 论坛和 stackoverflow,但我没有尝试解决我的问题。到目前为止,我们尝试过:

@Override
public void onDestroy() {
// TODO Auto-generated method stub
super.loadUrl("about:blank");
super.onDestroy();
}

我们还尝试了这个修复来增加超时 @覆盖 public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

    super.init();
super.setIntegerProperty("loadUrlTimeoutValue", 60000);
super.setBooleanProperty("keepRunning", false);
super.loadUrl(Config.getStartUrl());

我们的 config.xml 看起来像这样:

<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.helloCordova" version="2.0.0" xmlns="http://www.w3.org/ns/widgets">
<name>SellPro</name>
<description>
SellPro
</description>
<author email="support@vertinity.com" href="http://www.vertinity.com">
Vertinity LTD Team
</author>
<content src="index.html" />
<feature name="App">
<param name="android-package" value="org.apache.cordova.App" />
</feature>
<access origin="*" />
<preference name="useBrowserHistory" value="false" />
<preference name="exit-on-suspend" value="true" />
<preference name="fullscreen" value="false" />
<preference name="webviewbounce" value="true" />
<preference name="splashscreen" value="splash" />
<preference name="splashScreenDelay" value="10000" />
<feature name="File">
<param name="android-package" value="org.apache.cordova.core.FileUtils" />
</feature>
<feature name="FileTransfer">
<param name="android-package" value="org.apache.cordova.core.FileTransfer" />
</feature>
<feature name="ExtractZipFilePlugin">
<param name="android-package" value="org.apache.cordova.core.ExtractZipFilePlugin" />
</feature>
<feature name="PdfPanel">
<param name="android-package" value="com.vertinity.pdfPanel.PdfPanel" />
</feature>
<feature name="SocialShare">
<param name="android-package" value="com.vertinity.socialShare.SocialShare" />
</feature>
<feature name="Media">
<param name="android-package" value="org.apache.cordova.core.AudioHandler" />
</feature>
<feature name="MXPlayer">
<param name="android-package" value="com.vertinity.mxPlayer.MXPlayer" />
</feature>
<feature name="org.apache.cordova.core.ParsePlugin">
<param name="android-package" value="org.apache.cordova.core.ParsePlugin" />
</feature>
<feature name="WebIntent">
<param name="android-package" value="android.WebIntent" />
</feature>
<feature name="NetworkStatus">
<param name="android-package" value="org.apache.cordova.networkinformation.NetworkManager" />
</feature>
<feature name="SplashScreen">
<param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
</feature>
</widget>

我们的 andoidManifest 看起来像这样:

<?xml version='1.0' encoding='utf-8'?>
<manifest android:clearTaskOnLaunch="true"
android:hardwareAccelerated="true"
android:versionCode="4"
android:versionName="1.0.12"
package="com.mventix.sellPro"
xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="16" />
<application android:debuggable="true"
android:hardwareAccelerated="true"
android:largeHeap="true"
android:clearTaskOnLaunch="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:name=".sellProApplication" >
<activity android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
android:label="@string/app_name"
android:name="sellPro"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.facebook.LoginActivity"
android:label="@string/app_name" >
</activity>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/>
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
</application>
</manifest>

我希望有人能帮助我,或者只是向我解释到底发生了什么,这样我就可以开始朝着正确的方向进行研究。如果有人需要其他信息,我会提供所有需要的数据。

亲切的问候茨维坦

最佳答案

我记得有一次我遇到过类似的问题,当时我暂停了我的应用程序。不知何故(我不知道为什么)window.device从挂起模式返回时未正​​确(重新)初始化。

所以我决定给 phonegap 多 1000 毫秒的时间来获取它的 window.device

这是一个 smapleCode 来了解我的意思:

一切以init();开始

<body onload="init()">
</body>

还有 中的 ScriptBlock <head> 部分:

        <script type="text/javascript">

function init(){
console.log("init() called");
var promiseDeviceReady = onDeviceReady();
promiseDeviceReady.done(doPhoneGapStuff); //start PhoneGap action
}

function onDeviceReady() {
var deferred = $.Deferred();
var timeOut = 0;


//set a 1sec timeOut when App was send to suspendMode. SomeTimes PhoneGap needs it's time...
if (!window.device){
console.log("PhoneGap seems not to be ready yet!!!")
timeOut = 1000;
}

setTimeout(function() {
deferred.resolve();
}, timeOut);

return deferred.promise();
}

</script>

关于android - 回到前台时应用程序卡住(Cordova 3 + jquery mobile),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19519824/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com