how to skip an activity once its not needed? android [closed]
im doing a starting setup settings thing for my app and i was wondering how i can get it to skip the sign up page once they have already entered once? an if statement would be the thing I thought but im not so good with if statem开发者_开发知识库ents in android so could anyone point me in the direction for a solution?
Store a value in SharedPreferences
(e.g. boolean loggedIn=true
) once the login data has been entered and saved. Then every time you start your app get the value from SharedPreferences
and decide whether to show the login-window (loggedIn==false
) or not (loggedIn==true
).
I've done this by having an Activity with no UI as my startup activity which checks for the existence of a prefernce setting and then launches either the sign up activity or the main activity depending on whether or not the preference setting exists.
In the androidmanifest you can register your activity with no UI using something like this (if I remember correctly):
android:theme="@android:style/Theme.NoDisplay"
After launching your chosen activity you need to call finish() in the UI-less activity
you should maintain a boolean and save it in SharedPreference and check it there and perform your task accordingly.......
精彩评论