私はActivityexample.activity.SetupManageにいます。いくつかの操作の後、通知メッセージを表示するダイアログを呼び出します。ただし、[OK]ボタンをクリックしなくても、後続のすべてのコードが実行されるため、すべてのアクティビティを強制終了すると、ダイアログで問題が発生します。問題を解決するために何ができますか?
AlertDialog myAlertDialog;
public void onDestroy(Bundle savedInstanceState){
if(myAlertDialog.isShowing())
myAlertDialog.dismiss();
}
// *** some operations *** //
try{
myAlertDialog = new AlertDialog.Builder(this)
.setTitle("Notification")
.setMessage("Operation Failed")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
})
.show();
}
catch(Exception ex){
}
try{
Intent myIntent = new Intent();
myIntent.setClassName("example.activity", "example.activity.MainActivity");
myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|
Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(myIntent);
}catch(Exception ex){
}
エラーメッセージ:
10-16 15:33:11.120: E/WindowManager(4360): Activity example.activity.SetupManage has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@415ca638 that was originally added here
10-16 15:33:11.120: E/WindowManager(4360): at example.activity.SetupManage.CleanDatabase(SetupManage.java:61)
10-16 15:33:11.120: E/WindowManager(4360): at android.view.ViewRoot.<init>(ViewRoot.java:288)
10-16 15:33:11.120: E/WindowManager(4360): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:249)
10-16 15:33:11.120: E/WindowManager(4360): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:193)
10-16 15:33:11.120: E/WindowManager(4360): at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:118)
10-16 15:33:11.120: E/WindowManager(4360): at android.view.Window$LocalWindowManager.addView(Window.java:532)
10-16 15:33:11.120: E/WindowManager(4360): at android.app.Dialog.show(Dialog.java:269)
10-16 15:33:11.120: E/WindowManager(4360): at android.app.AlertDialog$Builder.show(AlertDialog.java:907)
10-16 15:33:11.120: E/WindowManager(4360): at example.activity.SetupManage.CleanDatabase(SetupManage.java:61)