私はAsyncTaskを持っていて、戻るボタンを押したときに実行をスティッチします。私はまた、以前に表示されたアクティビティに戻るようにアプリをしたい。私はタスクを停止して管理しているようだが、アプリケーションは以前のアクティビティに戻りません。何か案は?これは私のコードからの抜粋ですAndroid - 戻るボタンが押されたときにAsyncTaskを停止して前のアクティビティに戻る
private class MyTask extends AsyncTask<Void, Void, Void> implements OnDismissListener{
private boolean exception= false;
@Override
protected void onPreExecute(){
pd = ProgressDialog.show(
IscrizioniActivity.this,
"Please wait...",
"Loading the data",
true,
true,
new DialogInterface.OnCancelListener(){
public void onCancel(DialogInterface dialog) {
MyTask.this.cancel(true);
}
}
);
}
@Override
protected Void doInBackground(Void... voids) {
//do something
return (null);
}
@Override
protected void onPostExecute(Void voids) {
pd.dismiss();
//do something
}
public void onDismiss(DialogInterface dialog) {
this.cancel(true);
}
}
よろしくおねがいします。 、あなたの活動で
public void onDismiss(DialogInterface dialog) {
this.cancel(true);
IscrizioniActivity.this.finish();
}
この答えは役立つかもしれない - > http://stackoverflow.com/questions/7993023/stop-a-thread-downloading-images-activity-finished-finished/7993176#7993176 – guleryuz