Reputation: 39
I have a login activity, and in this activity I check if the user are already connected by checking a column value in the SQLite database.
My problem is when the user are already connected so I have to finish this activity and start another one, and that makes a bad animation, because the login activity opens and and then closes.
Upvotes: 1
Views: 45
Reputation: 4177
You can create an empty activity that only looks at the DB and launches the appropriate activity.
Assuming that you have 2 activities right now (Login and Main), the idea is that you'd have 3 activities:
In Root
's onCreate()
you'd check if the user is already logged in. If yes, then launch Main
. Otherwise launch Login
. You can keep the current logic Login
-> Main
.
Nguyen's answer keeps you to your 2 activities, but then the logic in the Main
activity is a bit more complicated.
Upvotes: 0
Reputation: 7603
Your current approach is:
Login_activity --> (login)--> Main_activity
My suggestion is:
Main_activity --> Check login --> if not logged in, start Login_activity
Upvotes: 1