android:name=".FrontScreenApplication"
FrontScreenApplication.class如下
public class FrontScreenApplication extends Application {
public static final String PREFS_NAME = "ApplicationFirstTime";
int PRIVATE_MODE = 0;
private static final String PREF_NAME2 = "LoginPref";
private static final String IS_LOGIN = "IsLoggedIn";
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
SharedPreferences pref = getSharedPreferences(PREFS_NAME, 0);
if (!pref.getBoolean("isFirstTime", false)) {
SharedPreferences.Editor editor = pref.edit();
editor.putBoolean("isFirstTime", true);
editor.commit();
Intent intent = new Intent(this, LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} else {
SharedPreferences prefs = getSharedPreferences(PREF_NAME2,MODE_PRIVATE);
boolean result = prefs.getBoolean(IS_LOGIN, false);
if (result) {
Intent intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} else {
Intent intent = new Intent(this, LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}
}
清单中的主要类是MainActivity,因此首先调用它,当我们返回时,每个活动都显示在backstack LoginAcivity和MainActivity中。
答案 0 :(得分:1)
您必须设置意图标记Intent.FLAG_ACTIVITY_CLEAR_TASK。这将解决您的问题。
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
OR
在AndroidManifest.xml文件中输入android:noHistory =" true"用于FrontScreenApplication活动。
OR
您可以通过其他方式完成此操作,只需在启动意图后完成FrontScreenApplication活动。
Intent intent = new Intent(Login.this, ReadPhoneNo.class);
intent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
答案 1 :(得分:0)
我们在intent精确语法中使用FLAG_ACTIVITY_CLEAR_TASK标志如下:
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);