【发布时间】:2019-08-12 01:41:49
【问题描述】:
当我的应用程序中有多个活动时,如何退出该应用程序?
我尝试过finish() 和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();
【问题讨论】:
标签: android activity-finish system.exit application-close