我的AsyncTask
上有WindowLeaks,我不知道如何处理它我甚至尝试在dismiss()
上放onPostExecute
但它仍然给我同样的问题。
protected void onPreExecute() {
if(this.showLoadingMessage) {
this.progressDialog = new ProgressDialog(this.context);
this.progressDialog.setMessage(this.loadingMessage);
this.progressDialog.show();
this.progressDialog.setCancelable(false);
}
super.onPreExecute();
}
protected void onPostExecute(String result) {
if(this.showLoadingMessage && this.progressDialog.isShowing()) {
this.progressDialog.dismiss();
}
result = result.trim();
if(this.asyncResponse != null) {
this.asyncResponse.processFinish(result);
}
if(this.exception != null) {
if(this.exceptionHandler != null) {
this.exceptionHandler.handleException(this.exception);
}
if(this.eachExceptionsHandler != null) {
Log.d(this.LOG, "" + this.exception.getClass().getSimpleName());
if(this.exception instanceof MalformedURLException) {
this.eachExceptionsHandler.handleMalformedURLException((MalformedURLException)this.exception);
} else if(this.exception instanceof ProtocolException) {
this.eachExceptionsHandler.handleProtocolException((ProtocolException)this.exception);
} else if(this.exception instanceof UnsupportedEncodingException) {
this.eachExceptionsHandler.handleUnsupportedEncodingException((UnsupportedEncodingException)this.exception);
} else if(this.exception instanceof IOException) {
this.eachExceptionsHandler.handleIOException((IOException)this.exception);
}
}
}
}
当此代码正常工作时会发生此泄漏。
HashMap postNotification = new HashMap();
postNotification.put("txtOwner", tvRenter.getText().toString());
AsyncClass taskCount = new AsyncClass(ownerAccept.this, postNotification, new AsyncResponse() {
@Override
public void processFinish(String s) {
if(s.contains("success")){
HashMap postNotif = new HashMap();
postNotif.put("txtOwner", tvRenter.getText().toString());
AsyncClass taskAdd = new AsyncClass(ownerAccept.this, postNotif, new AsyncResponse() {
@Override
public void processFinish(String s) {
if(s.contains("success")){
Log.d(TAG, s);
Intent in = new Intent(ownerAccept.this, RenterTabs.class);
startActivity(in);
finish();
}
}
});
taskAdd.execute("http://carkila.esy.es/carkila/notificationAccept.php");
} else {
Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_SHORT).show();
}
}
});
taskCount.execute("http://carkila.esy.es/carkila/notificationCount.php");
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
AlertDialog alert = a_accept.create();
alert.setTitle("Accept");
alert.show();
答案 0 :(得分:0)
你什么时候有这些泄漏?请记住,如果销毁AsyncTask的活动(或片段)被破坏,则会发生这些泄漏。