In your SplashScreen check if user is already authenticated using a flag in SharedPreferences
Use a worker thread to ensure some delay at splash-screen
in onCreate() of SplashScreen
onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView("<Layout id>");
Thread navThread = new Thread() {
@Override
public void run() {
try {
sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
navigateToHomeScreen();
}
};
navThread.start();
}
void navigateToHomeScreen(){
SharedPreferences preferences=c.getSharedPreferences("<Your pref name>", Context.MODE_PRIVATE);
if(preferences.contains("isAuthenticated")){
// Navigate to Main Activity
}else{
// Navigate to login Activity
}
finish();
}
In your login Activity once User is authenticated
SharedPreferences preferences=c.getSharedPreferences("<Your pref name>", Context.MODE_PRIVATE);
preferences.edit().putBoolean("isAuthenticated", true).apply();
// Navigate to Main Activity
Hints: Declare PrefName in some Constant file and access same wherever you want to access SharedPreferences.