简体   繁体   中英

Android phonegap app is slow

I have a html5/phonegap application. It runs slow on galaxy s3 or s4.

The logcat shows it has some 2-second delay here and there. Below are some examples.

05-19 12:30:27.148: D/webkit(14438): euler: isUrlBlocked = false
05-19 12:30:29.390: D/dalvikvm(14438): GC_FOR_ALLOC freed 1641K, 22% free 26652K/33832K, paused 18ms, total 19ms

...
05-19 12:30:30.331: D/webkit(14438): euler: isUrlBlocked = false
05-19 12:30:33.024: V/chromium_net(14438): external/chromium/net/socket/ssl_client_socket_openssl.cc:419: [0519/123033:INFO:ssl_client_socket_openssl.cc(419)] ~SSLClientSocketOpenSSL()

Any suggestions? Or any way to find out more details?

yep i also faced the same problem when developing my first Android Calculator. the problem is with all the CSS . if you have coded a lot of CSS and a lot of references. it will stuck in it.

or you can try to write all the CSS using inline method. and same with JavaScript like,

<html>
<head>
<title>Html calculator</title>
<style type="text/css" >

    body{
        background-color: #A7A6CC;
    }

    #bt{
    height:80px;
    width:80px;
    font-size:40px;
    background:#8987BA;
    }

    #ans{
    height:50px;
    background:#8987BA;
    font-size: 30px;
    }

    #main{
    text-align:center;
    }
</style>
</head>
<body >
<table id="main" align="center">
<tr>
<td>
 <form name="calculator" >
<input id="ans" style="width: 320px;" type="textfield" name="ans" value="">
<br>
<input id="bt" type="button" value="1" onClick="document.calculator.ans.value+='1'">
<input id="bt" type="button" value="2" onClick="document.calculator.ans.value+='2'">
<input id="bt" type="button" value="3" onClick="document.calculator.ans.value+='3'">
<input id="bt" type="button" value="+" onClick="document.calculator.ans.value+='+'">
<br>
<input id="bt" type="button" value="4" onClick="document.calculator.ans.value+='4'">
<input id="bt" type="button" value="5" onClick="document.calculator.ans.value+='5'">
<input id="bt" type="button" value="6" onClick="document.calculator.ans.value+='6'">
<input id="bt" type="button" value="-" onClick="document.calculator.ans.value+='-'">
<br>
<input id="bt" type="button" value="7" onClick="document.calculator.ans.value+='7'">
<input id="bt" type="button" value="8" onClick="document.calculator.ans.value+='8'">
<input id="bt" type="button" value="9" onClick="document.calculator.ans.value+='9'">
<input id="bt" type="button" value="x" onClick="document.calculator.ans.value+='*'">
<br>
<input id="bt" type="button" value="0" onClick="document.calculator.ans.value+='0'">
<input id="bt" type="reset" value="Reset">
<input id="bt" type="button" value="=" onClick="document.calculator.ans.value=eval(document.calculator.ans.value)">
<input id="bt" type="button" value="&divide;" onClick="document.calculator.ans.value+='/'">
</form>
</td>
</tr>
</table>

</body>
</html>

Design of Code

then it works well. try more tips. at

http://phonegap.com/blog/2013/07/25/tips-for-developing-apps-with-pg/

hope it will help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM