我想在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