0

I made an android app and I have added an agreement activity in it.But every time I start the app it starts the agreement page.I want that After the application is installed,it should not show the agreement page every time but a specific activity should be launched.How to do that?

Kme
  • 103
  • 1
  • 11

2 Answers2

1

You might want to use SharedPreferences

SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
boolean wasShown = prefs.getBoolean("agr", false);
if(!wasShown) {
    showAgr();
    prefs.edit().putBoolean("agr", true).commit();
}
Alexander Kulyakhtin
  • 47,782
  • 38
  • 107
  • 158
  • I am sorry but I am not getting,what you are saying.I have set the agreement as the first activity to be launched when I launch the application.And when app starts,Agreement page come in front of user by default – Kme May 27 '14 at 06:26
  • Then, check as above in your activity's onCreate and if the agreement has already been shown call finish() and then startActivity for your next activity from within your onCreate – Alexander Kulyakhtin May 27 '14 at 06:26
0

Use SharedPreferences to identify whether the app is running for the first time.

Look at this question

Community
  • 1
  • 1
Rajitha Siriwardena
  • 2,749
  • 1
  • 18
  • 22