ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

android – 返回前台时应用程序冻结(Cordova 3 jquery mobile)

2019-07-03 14:18:14  阅读:205  来源: 互联网

标签:android cordova jquery-mobile performance


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

similar bug

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

这个问题代表了(android 4.0.3,4.1.2,4.2.2),这些设备是LG硝基,HP板岩7三星GT2 7inch三星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>

我希望有人可以帮助我,或者只是向我解释究竟发生了什么,这样我才能开始研究正确的方向.如果有人需要其他信息,我将提供所需的所有数据.

亲切的问候Tsvetan

解决方法:

我记得,一旦我有类似的问题,暂停我的应用程序.
不知怎的(我不知道为什么)window.device在从suspendmode返回时没有被正确地重新初始化.

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

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

一切都以init()开头;

<body onl oad="init()">
</body>

并且< head>中的ScriptBlock部分:

        <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,jquery-mobile,performance
来源: https://codeday.me/bug/20190703/1367515.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有