我想在Android中關閉總體應用程序時,我點擊對話框中的「否」按鈕。我已經使用了下面的代碼。如何殺死android應用程序中的所有活動?
protected Dialog onCreateDialog(int id) {
switch (id) {
case 0:
AlertDialog.Builder builder1 = new AlertDialog.Builder(this);
builder1.setTitle("GASIMIZER");
builder1.setCancelable(false)
.setPositiveButton("YES",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int which) {
Intent i = new Intent(Finalpage.this,NewproActivity.class);
startActivity(i);
}
})
.setNegativeButton("NO",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int which)
{
quit();
}
});
AlertDialog alert1 = builder1.create();
alert1.show();
break;
}
return null;
}
public void quit() {
onDestroy();
}
請任何一個告訴我如何解決這個問題。
這裏是關閉所有活動的最佳解決方案: http://stackoverflow.com/a/5453228/1464582 – 2013-02-03 08:39:50