当我在该应用程序中有多个活动时如何退出android中的应用程序?
我试过finish()
and System.exit(0)
,但没有一个奏效。它所做的只是转到上一个活动。
这是我的代码:
boolean insertionStatus = mydb.DataInsertion(email, password, username, fathername, contact, birthday, user_address);
if (insertionStatus)
{
alert.setTitle("Registration Status");
alert.setMessage("You are successfully registered!\nDo you want to login now?");
alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(RegistrationActivity.this, LoginActivity.class);
startActivity(intent);
}
});
alert.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
System.exit(0);
}
});
alert.create().show();