Smi*_*ife 9 multithreading android
我正在使用HttpURLConnection来获取一个Web服务,服务器在同一个网络中,但响应可以延迟到60000ms(bcs的一些复杂的原因,我必须将它设置为60000ms),当我点击listview项目来调用web服务和等待响应并松开wifi信号并继续单击列表我的应用程序崩溃没有异常错误A/libc(9052): Fatal signal 6 (SIGABRT) on android at 0x000001e5 (code=0), thread 9052
更明确:webservice call+ wifi lost+ clicks = Fatal signal 6 code=0
我试图通过以下方式避免这种情况:
避免UI cliks
但没办法!请帮助,任何propo和讨论是apreciated ..
public static boolean stopUserInteractions=false;
private class GetXmlAndStopUI extends AsyncTask<List, Void, String> {
private final ProgressDialog dialog = new ProgressDialog(context);
@Override
protected void onPreExecute() {
this.dialog.setMessage("Please wait...");
this.dialog.setCancelable(false);
this.dialog.show();
}
@Override
protected String doInBackground(final List... items) {
runOnUiThread(new Runnable() {
@Override
public void run() {
webserviceCall(items[0]);
}
});
return "MSG";
}
@Override
protected void onPostExecute(String result) {
stopUserInteractions=false;
if (this.dialog.isShowing()) {
this.dialog.dismiss();
}
}
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (stopUserInteractions) {
Toast.makeText(context, "STOP!!!!", Toast.LENGTH_SHORT).show();
return true;
} else {
return super.dispatchTouchEvent(ev);
}
}
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
19352 次 |
| 最近记录: |