有意圖觸發的活動:設置,顯示和隱藏ProgressDialog。當它設置並顯示活動正常工作時,但是當調用hide時,不是調用onDestroy方法,而是調用onCreate。這裏是一個的logcat當活動開始:Android活動調用onCreate而不是onDestroy。爲什麼?
SHOW_PROGESS
SET_PROGESS
onCreate
onStart
onResume
SET_PROGESS
onPause
DialogSET 15
onResume
SET_PROGESS
onPause
DialogSET 16
onResume
...
的ProgressDialog被設定並在onNewIntent(意向意圖)所示的方法。但是,當隱藏任務被稱爲
pd.dismiss();
finish();
被調用,而不是調用的onDestroy的的onCreate被稱爲:
HIDE_PROGESS
onPause
DialogHIDE
onResume
onPause
onCreate
onStart
onResume
onStop
destroyed
Activity -activityName- has leaked window [email protected] that was originally added here android.view.WindowLeaked
有白色顯示沒有ProgessDialog。按下後退按鈕後,
onPause
onDestroy
被調用,然後我可以看到我想要的掃管笏。我該如何解決這個問題,我不應該按下BACK按鈕來再次調用onDestroy?
的意圖開始是這樣的:
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.setAction(intent.ACTION_VIEW);
startActivity(intent);
謝謝!
編輯:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
extras = getIntent().getExtras();
progress = 0;
max = extras.getInt("max");
title = extras.getInt("title");
pd = new ProgressDialog(this);
pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
pd.setCancelable(false);
Log.w("screenPD", "onCreate");
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
int newTitle = intent.getExtras().getInt("title");
if (intent.getExtras().getString("action").equals("set")){
pd.setTitle(newTitle);
pd.setMessage(intent.getExtras().getString("message"));
max = intent.getExtras().getInt("max");
pd.setMax(max);
pd.setProgress(intent.getExtras().getInt("progress"));
pd.show();
Log.e("DialogSET", "DialogSET "+intent.getExtras().getInt("progress"));
}
else if (intent.getExtras().getString("action").equals("show")){
pd.setProgress(intent.getExtras().getInt("progress"));
pd.setMessage(intent.getExtras().getString("message"));
//pd.show();
Log.e("DialogSHOW", "DialogSHOW "+progress);
}
else if (intent.getExtras().getString("action").equals("hide")){
//pd.dismiss();
finish();
Log.e("DialogHIDE", "DialogHIDE");
}
}
發佈您的代碼。 – 2012-07-15 09:36:23
我發佈了我的代碼 – Alex 2012-07-15 09:46:14