这是我正在尝试做的事情:
注意:网站和Android应用同时运行
Android部分:
try
{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://.../save.php");
httppost.setEntity(new UrlEncodedFormEntity(data));
HttpResponse response = httpclient.execute(httppost);
Log.i("postData", response.getStatusLine().toString());
//Could do something better with response.
}
catch(Exception e)
{
Log.e("log_tag", "Error1: " + e.toString());
}
JS部分
setInterval("DisplayBall()", 500);
function DisplayBall()
{
var xmlHttp = getXMLHttp();
xmlHttp.onreadystatechange = function()
{
if(xmlHttp.readyState == 4)
{
document.getElementById("TotalTime").value = 0;
//alert(xmlHttp.responseText);
AssignResult(xmlHttp.responseText);
}
}
//xmlHttp.open("GET", "TINBCoordinates.txt", true);
//xmlHttp.send();
xmlHttp.open("GET", "read.php", true);
xmlHttp.send();
}
为什么这两个干扰&让我的程序没有反应?
答案 0 :(得分:0)
切换到使用PhoneGap.js,这将为您节省大量时间。