나는 AsyncTask
에 WindowLeaks가 있는데 어떻게 처리해야할지 모르겠다. onPostExecute
에 dismiss()
을 넣으려고 했는데도 여전히 같은 문제가 발생했다.AsyncTask의 WindowLeaked
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();
'context'는 어디에서 왔습니까? 'context'를 제공하는'Activity'를 끝내고 있다면 당신은 누출로 끝날 것입니다. – Pztar
'LogCat'을 게시 할 수 있습니까? 이전 작업을 해지하고 작업을 끝내지 않고 새로운 '대화 상자'를 표시하기 때문에 문제를 일으키는 것으로 보이는 첫 번째 콜백에서 새 작업을 실행하는 것처럼 보입니다. – Pztar