Reputation: 1
android:name=".FrontScreenApplication"
FrontScreenApplication.class is as follows
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);
}
}
}
Main class in manifest is MainActivity so it is called first,when we go back, each activity is shown in backstack LoginAcivity and MainActivity.
Upvotes: 0
Views: 52
Reputation: 1340
You have to set intent flag Intent.FLAG_ACTIVITY_CLEAR_TASK.This will resolve your issue.
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
OR
In AndroidManifest.xml file put android:noHistory="true" for FrontScreenApplication activity.
OR
You can do it by another way ,simply finish the FrontScreenApplication activity after starting the intent.
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();
Upvotes: 1
Reputation: 191
We use FLAG_ACTIVITY_CLEAR_TASK flag in the intent exact syntax is as below:
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
Upvotes: 0