Search code examples
javaandroidandroid-layoutauthenticationskip

How to skip LoginActivity after a successful try the first time you run the Android app


I'm new to Java/Android programming. I'm getting to know how the layout works and how to redirect it. I've got a splash screen > login > main . Now I want to skip the login activity. How can I do it ?


Edit:

This is what my code looks like now, after answer:

SharedPreferences prefs = getSharedPreferences("myPref", 0); 
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("Bool", true);
editor.commit();

How I check from my Splashscreen:

SharedPreferences prefs = getSharedPreferences("myPref", 0); 
   if (prefs.getBoolean("Bool", false)) { //login_activity; }
   else{ //maint_activity;

I think this would work.


Solution

  • You can use SharedPreferences to store some boolean value like skipLogin. During splash screen you can check this value, and display login or main, depending on result.