1

我有 3 个不同的页面,目前只有第一个包含更多的逻辑和变量。当我用我的 Nexus 7 测试滑块时,我得到了这个:

07-24 09:36:01.363: D/Cordova(10976):
onPageFinished(file:///android_asset/www/index.html#/android_asset/www/testSlider.html)
07-24 09:36:01.363: D/CordovaWebView(10976): >>> loadUrlNow()
07-24 09:36:01.363: D/DroidGap(10976): onMessage(onNativeReady,null)
07-24 09:36:01.363: D/DroidGap(10976):
onMessage(onPageFinished,file:///android_asset/www/index.html#/android_asset/www/testSlider.html)
07-24 09:36:17.463: D/dalvikvm(10976): GC_CONCURRENT freed 470K, 10%
free 8084K/8967K, paused 19ms+7ms, total 83ms

那么是关于内存还是jquery移动滑块中存在巨大的内存泄漏?甚至有可能吗,因为我只有 3 个几乎是空的页面,最后一个是滑块(虽然不工作),它们在浏览器中工作,但在 nexus 7 中没有。

如果有人在phonegap + jqm + Android中实现了多页面应用程序,你能告诉我这是否可能,如果是的话,我如何增加Nexus或模拟器中jvm的内存量或如何管理我的应用程序中的内存使用. 我刚刚将几个控制台日志插入到滑块以检查它是否工作,但我只是得到了那个内存行,根本没有日志,就像我说的那样,它在浏览器中工作,但在真实设备中没有。

代码在这里

package com.mycordova.hellocordova;

import android.R;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;
import org.apache.cordova.*;

public class HelloCordovaActivity extends DroidGap {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.loadUrl("file:///android_asset/www/index.html");
    }

}

<!DOCTYPE html>
<html>
<head> 

<title>conditions</title> 
<meta name="viewport" content="width=device-width, initial-scale=1"> 
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>


<script type="text/javascript">
function onload(){
    $("#temperature").on("change", function(e){
        var newTemp = $("#temperature").val();
        console.log("newTempnewTempnewTempnewTemp---->" +newTemp)
        $("#temp").val(newTemp);
    });


}

</script>

</head> 

<body onload="onload()"> 
<div data-role="page" data-theme="a">
    <div data-role="header">


<h1>Conditions</h1>
    </div>


    <div data-role="fieldcontain">
        <label for="temperature">Temperature22:</label>
        <input type="range" name="temperature" id="temperature" value="15" min="-15" max="60" data-highlight="true" />
        <label for="temp">Echo Temp</label>
        <input type="text" value="" id="temp" />
    </div>
</div>
</body>
</html>

从一页到另一页的跳转就是这样发生的。条件页面是有问题的!

<div data-role="footer" data-position="fixed">
    <div data-role="navbar" style="font-size: -2">
        <ul>
        <li><a href="index.html" class="ui-btn-active">Index</a></li>
        <li><a href="conditions.html" data-transition="pop"
        data-direction="reverse">Conditions</a></li>

    </ul>
    </div>
</div>

现在的情况是滑块页面(称为条件)在第一页时工作正常,但在第二页时它不再工作。我试图将两个页面都放在第一页中,但最终结果相同。但这很有帮助,因为我一直在指责 JQM 和我的 jS,所以现在我知道这是另外一回事。

顺便说一句,当我在浏览器中测试我的应用程序时,它不起作用,但是当我刷新页面时,它就会开始工作。这是我做过的最奇怪的应用程序。

@tencent 询问更多日志,这里是:

07-24 23:26:59.910: D/Cordova(20550): onPageFinished(file:///android_asset/www/index.html#conditions)
07-24 23:26:59.910: D/CordovaWebView(20550): >>> loadUrlNow()
07-24 23:26:59.910: D/DroidGap(20550): onMessage(onNativeReady,null)
07-24 23:26:59.910: D/DroidGap(20550): onMessage(onPageFinished,file:///android_asset/www/index.html#conditions)---> Transition to next page where that slider is.
07-24 23:27:21.490: D/SoftKeyboardDetect(20550): Ignore this event**----> I Tried to write to disabled echo-fied**
07-24 23:27:21.690: D/SoftKeyboardDetect(20550): Ignore this event
07-24 23:27:28.120: D/SoftKeyboardDetect(20550): Ignore this event
07-24 23:27:33.470: D/CordovaWebView(20550): >>> loadUrlNow()
07-24 23:27:33.470: D/DroidGap(20550): onDestroy()**--->Somewhere here it crashed and closed the app!!**
07-24 23:27:33.480: D/CordovaWebView(20550): >>> loadUrlNow()
07-24 23:27:33.480: D/CordovaWebView(20550): >>> loadUrlNow()
07-24 23:27:33.670: D/DroidGap(20550): DroidGap.onCreate()
07-24 23:27:33.690: D/CordovaWebView(20550): Origin to allow: http://127.0.0.1*
07-24 23:27:33.690: I/CordovaLog(20550): Found log level DEBUG
07-24 23:27:33.690: I/CordovaLog(20550): Changing log level to DEBUG(3)
07-24 23:27:33.690: I/CordovaLog(20550): Found preference for useBrowserHistory=false
07-24 23:27:33.690: D/CordovaLog(20550): Found preference for useBrowserHistory=false
07-24 23:27:33.700: D/DroidGap(20550): DroidGap.init()
07-24 23:27:33.700: D/CordovaWebView(20550): >>>loadUrl(file:///android_asset/www/index.html)
07-24 23:27:33.700: D/PluginManager(20550): init()
07-24 23:27:33.700: D/CordovaWebView(20550): >>> loadUrlNow()
07-24 23:27:33.710: D/CordovaLog(20550): exception firing pause event from native
07-24 23:27:33.710: D/CordovaLog(20550): null: Line 1 : exception firing pause event from native
07-24 23:27:33.710: I/Web Console(20550): exception firing pause event from native at null:1
07-24 23:27:33.710: D/CordovaLog(20550): exception firing destroy event from native
07-24 23:27:33.710: D/CordovaLog(20550): null: Line 1 : exception firing destroy event from native
07-24 23:27:33.710: I/Web Console(20550): exception firing destroy event from native at null:1
07-24 23:27:33.710: D/SoftKeyboardDetect(20550): Ignore this event
07-24 23:27:33.730: D/DroidGap(20550): onMessage(onPageStarted,about:blank)
07-24 23:27:33.730: D/Cordova(20550): onPageFinished(about:blank)
07-24 23:27:33.730: D/DroidGap(20550): onMessage(onPageFinished,about:blank)
07-24 23:27:33.730: D/DroidGap(20550): onMessage(exit,null)
07-24 23:27:33.760: D/DroidGap(20550): onMessage(onPageStarted,file:///android_asset/www/index.html)
07-24 23:27:33.770: D/CordovaWebView(20550): >>> loadUrlNow()
07-24 23:27:33.810: D/SoftKeyboardDetect(20550): Ignore this event
07-24 23:27:33.820: D/DroidGap(20550): onDestroy()
07-24 23:27:33.820: D/CordovaWebView(20550): >>> loadUrlNow()
07-24 23:27:33.820: D/CordovaWebView(20550): >>> loadUrlNow()
07-24 23:27:34.160: W/IInputConnectionWrapper(20550): showStatusIcon on inactive InputConnection
07-24 23:27:34.250: D/CordovaLog(20550): exception firing pause event from native
07-24 23:27:34.250: D/CordovaLog(20550): null: Line 1 : exception firing pause event from native
07-24 23:27:34.250: I/Web Console(20550): exception firing pause event from native at null:1
07-24 23:27:34.260: D/CordovaLog(20550): exception firing destroy event from native
07-24 23:27:34.260: D/CordovaLog(20550): null: Line 1 : exception firing destroy event from native
07-24 23:27:34.260: I/Web Console(20550): exception firing destroy event from native at null:1
07-24 23:27:34.260: D/Cordova(20550): onPageFinished(file:///android_asset/www/index.html)
07-24 23:27:34.260: D/CordovaWebView(20550): >>> loadUrlNow()
07-24 23:27:34.260: D/DroidGap(20550): onMessage(onNativeReady,null)
07-24 23:27:34.260: D/DroidGap(20550): onMessage(onPageFinished,file:///android_asset/www/index.html)
07-24 23:27:34.270: D/DroidGap(20550): onMessage(onPageStarted,about:blank)
07-24 23:27:34.290: D/Cordova(20550): onPageFinished(about:blank)
07-24 23:27:34.290: D/DroidGap(20550): onMessage(onPageFinished,about:blank)
07-24 23:27:34.300: D/DroidGap(20550): onMessage(exit,null)
07-24 23:27:36.270: D/DroidGap(20550): onMessage(spinner,stop)
07-24 23:27:36.300: D/DroidGap(20550): onMessage(spinner,stop)
4

0 回答 0