所以我有一个成功的应用程序,它有一个在我的网站上注册用户的表单,我创建了一个 15 帧的 png 动画,它在命令下也能很好地运行。
我让动画首先启动(并且正在循环),然后在动画结束时运行 HTTP POST。当 HTTP Post 正在做它的事情时,动画(几乎所有的 android)会滞后或暂停,然后在 POST 完成后继续运行。
这是正常的吗?有没有办法让它在运行 POST 时不滞后?
谢谢!
对于那些好奇的人,这是我的 httpClass(mywebsite.com 只是我实际 URL 的一个道具)
try{
Log.d("MYTAG", "Registration begin");
HttpClient client = new DefaultHttpClient();
String postURL = "mywebsite.com";
HttpPost post = new HttpPost(postURL);
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("username", username));
params.add(new BasicNameValuePair("password", password));
params.add(new BasicNameValuePair("email", email));
params.add(new BasicNameValuePair("fullName", fullName));
UrlEncodedFormEntity ent = new UrlEncodedFormEntity(params);
post.setEntity(ent);
HttpResponse responsePOST = client.execute(post);
HttpEntity resEntity = responsePOST.getEntity();
if(resEntity!=null){
newCode = EntityUtils.toString(resEntity);
} else {
newCode = (String) null;
}
}catch(Exception e){
Log.d("MYTAG", "Exception e="+e);
}
return newCode;
}