Skip to content Skip to sidebar Skip to footer

How To Skip The Signup Activity And Proceed To The Homescreen In Android

I have Profile class where the user enters his name and email. but whenever I open the app it asks the user to enter name. how do I skip this and make it show it to the user only o

Solution 1:

You can use Shared Preferences.

Upon input of the username, when the user click button to next, call this:

SharedPreferencessp= context.getSharedPreferences("com.your.package", Context.MODE_PRIVATE);
SharedPreferences.Editoreditor= sp.edit();

editor.putBoolean("has_username", true); //save that the user enters username

editor.apply();

And on your ProfileActivity onCreate():

SharedPreferencessp= context.getSharedPreferences("com.your.package", Context.MODE_PRIVATE);

booleanhasUsername= sp.getBoolean("has_username", false);

if (hasUsername) { //checks if the user already input username to skip this activityIntentintent=newIntent(ProfileActivity.this, YourNextActivity.class);
   startActivity(intent);
   finish();
}

Solution 2:

You can use shared preference for store the boolean value. Once user signed in change the boolean state, Next time check that boolean value before executing your code

Post a Comment for "How To Skip The Signup Activity And Proceed To The Homescreen In Android"