我正在学习在android中开发,我需要您的帮助。 这是我用它来收我的应用程序...关闭应用程序并在启动器上打开
boolean twice;
@Override
public void onBackPressed() {
if(twice) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
System.exit(0);
}
twice = true;
toastMessage(getResources().getString(R.string.msg0a));
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
twice = false;
}
}, 2000);
}
问题是,当我回到我的应用程序在其最后一次活动开,我whant它LAUNCHER活动开放。
编辑:其原因是:我有一个活动,用户可以从帐户登录和登录活动的命运。注销后,当用户打开我的应用程序时,他必须一次又一次地通过登录活动,而他不登录。
只需调用finish(); inside onBackPressed() –
@ dcd4u2:你能告诉我们你是如何回到应用程序?通过应用程序图标在家里或最近的屏幕? – AndiGeeky
@AndiGeeky:是的,通过家里的图标。 – dcd4u2