android.view.WindowLeaked: Activity progressDialog show dismiss cancel

在发送服务请求的时候可能回在 标红 的位置报错


@Override

protected void onPreExecute() {
progressDialog = new ProgressDialog(mContext);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setMessage("登录中......");
progressDialog.setCancelable(false);
progressDialog.show();
super.onPreExecute();

}

@Override
protected void onPostExecute(Integer result) {
if (progressDialog != null) {
// progressDialog.dismiss();
progressDialog.cancel();

}
Message msg = new Message();
if (C.SUCCESS == result.intValue()) {
msg.getData().putString("msg", "");
msg.what = C.SUCCESS;
handler.sendMessage(msg);


} else if (C.FAILURE == result.intValue()) {
msg.getData().putString("msg", "");
msg.what = C.FAILURE;
handler.sendMessage(msg);


} else if (C.NETWORK == result.intValue()) {
msg.getData().putString("msg", "");
msg.what = C.NETWORK;
handler.sendMessage(msg);
}
}

是因为在上一Activity 送发送请求之后 直接就关闭了本Activity, progressDialog 还没有显示但是他所在的Activity已经关闭没有给他提供显示的界面所以会报错,那么把 跳转 inten finish()t  写到 handle 里面这样就可以解决了


你可能感兴趣的:(Android)