I have an application which uses Login. I want run this activity only if the user has not previously logged on. But this is my default activity. Is there a method to skip the default activity and go to the next activity directly?
You should call, from your Login Activity, the next Activity (e.g. Profile) for it purpose. The app workflow is:
1. Start Login Activity (by default);
2. Check login state;
3. If user already logged - start new Activity and close this.
How to do that?
To call new Activity you should use Intent. To close current, so user can't go back to the Login Activity later, you should clear current app backstack (i.e activity history). Also, you can reset transition animation, so user (if logged) not even notice that Login Activity was called.
private void startProfileActivity() {
Intent intent = new Intent(this, ProfileActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); //clear backstack
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); //it will looks like the transition inside the app, so user will not notice login activity, instead of default animation, which look like starting other app.
startActivity(intent);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With