-3

I want to run a piece of code that will check if my app is first time installed and show my activity just like a tutorial(example: if a person installed a game their show some tutorial how to play the game) for the first time user. I have a 3 activity which is Splash screen, the main Activity and the profile. I don't know how to achieve it.

edi9999
  • 19,701
  • 13
  • 88
  • 127
ziah299
  • 17
  • 2
  • 7

2 Answers2

3

The easiest thing you can do is save a boolean in sharedPreferences when your app runs and then check for it everytime your app starts, something like this:

if (mySharedPreferences().appAlreadyRun) {
    //Your app has already been run at least once, so don't show tutorial
}
else{
    //Your app is running for the first time
    showTutorial();
    mySharedPreferences().appAlreadyRun = true
}

Notice that this won't work, it's just "pseudoCode" to help you get the idea. Hope it helps

Sherekan
  • 536
  • 3
  • 14
0

You should store a setting that you the user has runned it at least once.

If the settings is not there: first time If the settings is there: n th time

You can store the setting using SharedPreferences: link to Android Dev

RvdK
  • 19,580
  • 4
  • 64
  • 107