Reputation: 123
We are developing a mobile application using latest AC (3.1.0) + jquery mobile. The application is live on google play store (https://play.google.com/store/apps/details?id=com.mventix.sellPro&hl=bg) but we are having strange issue. When the app is started there is no problem of opening different views and do some stuff. But when the application goes in background for some period of time (as far as it happens between 10minutes and 2-3 hours) and after resuming the application the user interface is frozen and nothing is responding also no error is printed in logcat. We have to kill the application and restart it to make it work. Also we are using WEBSQL and LocalStorage also we are storing some files in the app/cache/ because the app needs to run without internet. And we are using a lot of the plugins that are in cordova. I found similar bugs in apache cordova bugtracker but they are for older cordova versions.
In both places the problem looks similar but as far as i understand they are fixed in the latest cordova version.
This problem is represented over (android 4.0.3, 4.1.2, 4.2.2) over those devices are LG nitro, HP slate 7 Samsung GT2 7inch samsung sIII and s IV.
In that order i read and search all around the phonegap forum and stackoverflow but nothing that i've tried fixed my problem. As far now we tried:
@Override
public void onDestroy() {
// TODO Auto-generated method stub
super.loadUrl("about:blank");
super.onDestroy();
}
Also we tried this fix to make bigger timeout @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
super.init();
super.setIntegerProperty("loadUrlTimeoutValue", 60000);
super.setBooleanProperty("keepRunning", false);
super.loadUrl(Config.getStartUrl());
Our config.xml looks like this:
<?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="[email protected]" 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>
Our andoidManifest looks like this:
<?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>
I hope someone can help me or just explain me what exactly is happening so I can start researching in the right direction. If someone needs additional info I will provide all the data needed.
Kind Regards Tsvetan
Upvotes: 4
Views: 3249
Reputation: 274
I can remember that once i've had similar issues, when suspending my app.
Somehow (i do not know why) window.device
has'nt been (re)initialized properly when returning from suspendmode.
So i've decided to give phonegap a 1000ms more time on getting it's window.device
Here is a smapleCode to get an idea of what i mean:
Everything start with init();
<body onload="init()">
</body>
And a ScriptBlock in the <head>
section:
<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>
Upvotes: 2