I am working on an application which contain register activity as it's first page which is on tabs. i want that once the user is register then whenever the user starts the application it should always run from main menu screen and should never display the register screen till the user uninstall the application and reinstall it again.
Asked
Active
Viewed 80 times
0
-
use sharedpreference to maintain flag value..look at this answer http://stackoverflow.com/a/9964744/603744 – Andro Selva Jun 27 '12 at 12:59
-
you should use [android-activity] tag instead of [activity] – Alex Lockwood Jun 27 '12 at 13:00
2 Answers
1
you can use SharedPreferences. This is an example:
SharedPreferences mPrefs = getSharedPreferences("MyPreferences", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean("firstTime", true);
editor.commit();
So you can check if firstTime is true doing this:
SharedPreferences mPrefs = getSharedPreferences("MyPreferences", Context.MODE_PRIVATE);
if(mPrefs.getBoolean(firstTime, false){
//show screen
}
Stefano Ortisi
- 5,288
- 3
- 33
- 41
-
thanks for your replies...can you please tell where exactly do i put this SharedPreferences code?? – arsh.somal Jun 27 '12 at 16:29
-
You can put this code in your Activity entry point, the first Activity you reach when the app starts. – Stefano Ortisi Jun 27 '12 at 16:31
0
Set your AndroidManifest to start the MainActivity as the default activity.
Then in the onCreate check if the user has registered (perhaps store this in SharedPreferences), if they have NOT registered - instantly start the intent for your RegisterActivity, otherwise carry on as normal.
Blundell
- 75,855
- 30
- 208
- 233