Android 返回前台时应用程序冻结(Cordova 3和jquery mobile)
我们正在使用最新的AC(3.1.0)+jquery mobile开发一个移动应用程序。该应用程序在google play store()上运行,但我们遇到了一个奇怪的问题。当应用程序启动时,打开不同的视图并执行一些操作是没有问题的。但当应用程序在后台运行一段时间(只要发生在10分钟到2-3小时之间),并且在恢复应用程序后,用户界面被冻结,没有任何响应,logcat中也不会打印错误。我们必须关闭应用程序并重新启动它以使其正常工作。此外,我们正在使用WEBSQL和LocalStorage,我们还在app/cache/中存储一些文件,因为应用程序需要在没有internet的情况下运行。我们正在使用cordova中的许多插件。 我在ApacheCordovaBugTracker中发现了类似的错误,但它们适用于较旧的cordova版本 在这两个地方的问题看起来相似,但据我所知,他们是在最新的科尔多瓦版本修复 在LG nitro、HP slate 7三星GT2 7英寸三星sIII和s IV等设备上(安卓4.0.3、4.1.2、4.2.2)都出现了这个问题 按照这个顺序,我在phonegap论坛和stackoverflow上到处阅读和搜索,但我没有尝试过解决我的问题。 到目前为止,我们尝试:Android 返回前台时应用程序冻结(Cordova 3和jquery mobile),android,performance,jquery-mobile,cordova,Android,Performance,Jquery Mobile,Cordova,我们正在使用最新的AC(3.1.0)+jquery mobile开发一个移动应用程序。该应用程序在google play store()上运行,但我们遇到了一个奇怪的问题。当应用程序启动时,打开不同的视图并执行一些操作是没有问题的。但当应用程序在后台运行一段时间(只要发生在10分钟到2-3小时之间),并且在恢复应用程序后,用户界面被冻结,没有任何响应,logcat中也不会打印错误。我们必须关闭应用程序并重新启动它以使其正常工作。此外,我们正在使用WEBSQL和LocalStorage,我们还在a
@Override
public void onDestroy() {
// TODO Auto-generated method stub
super.loadUrl("about:blank");
super.onDestroy();
}
我们还尝试了此修复,以使超时时间更长
@凌驾
创建时的公共void(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState)
我们的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>
<?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>
塞尔普
塞尔普
Vertinity有限公司团队
我们的清单如下所示:
<?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>
<?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>
我希望有人能帮助我,或者只是解释一下到底发生了什么,这样我就可以开始朝着正确的方向进行研究。如果有人需要额外的信息,我会提供所有需要的数据
感谢Tsvetan我记得曾经有过类似的问题,当我暂停我的应用程序时。 不知何故(我不知道为什么)
窗口。设备从suspendmode返回时未正确(重新)初始化
所以我决定给phonegap一个1000毫秒的时间来获取它的窗口
这里有一个简单的代码来理解我的意思:
一切都以init()开头;
<body onload="init()">
</body>
以及
部分中的脚本块:
<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>
函数init(){
log(“init()被调用”);
var promisedevicerady=ondevicerady();
promiseDeviceReady.done(doPhoneGapStuff);//启动PhoneGap操作
}
函数ondevicerady(){
var deferred=$.deferred();
var超时=0;
//将应用程序发送到suspendMode时设置1秒超时。有时PhoneGap需要它的时间。。。
如果(!window.device){
log(“PhoneGap似乎还没有准备好!!!”)
超时=1000;
}
setTimeout(函数(){
延迟。解决();
},超时);
延迟返回。承诺();
}