I’m currently trying to develop an android application in eclipse(java) which shows some jokes downloaded from a database. The user is able to vote on each joke once, and to make sure they only do that once, I have made a table in the database that contains three columns.
- Username (Used when a user publishes a joke)
- Encrypted Password
I have two “screens” right now:
- Login screen
- Main screen
At every single start up the application checks the SharedPreferences for a file containing some information, and if there is some information it should load the Main screen, but if there is no account information the Login screen should be loaded.
Any idea on how I can use different screens, and how should it be coded?
Two options:
Activity, check if there is account info. If there isn’t thensetContentViewto the Log in screen. Otherwise,setContentViewto your other content. If you go this route, you’ll have to have the logic of both the loginActivityand the other in the same Activity. Shouldn’t be too bad if the logic is relatively uncomplicated.Activity, but inonCreate()you can check if the info already exists and if it does, simply start the otherActivityright away and return fromonCreate(). Otherwise, continue withsetContentView, etc.