0

I am new to android development, and developing a small app for practice purposes. I want the following: When the user installs the app, he/she is greeted with a set of welcome pages, that give details about the app, and then proceeds to the actual app. But I don't want that set of pages to appear anytime after the first time the app is opened. So how do I go about implementing that?

PS: This is my first question posted, excuse typos or brevity if any.

Edit: It seems like there is another question of the same context, but I also want to know how to make such an activity that will load only once after the installation.

Varun Rao
  • 453
  • 2
  • 5
  • 9

2 Answers2

0

You can achieve this result in different way, one of them may be to store on SharedPreference

isFirstLoad = true

after the user read you intro page then

isFirstLoad = false

in your main activity check for first load to redirect user to correct activity

Intent i = ...// normal activity
if(isFirstLoad){
    i = ...// intro activity
}
startActivity(i);
Marco Luongo
  • 397
  • 4
  • 13
0

you should use SharedPrefrences for store that it is the first time or not. you can creat a class for store information like this.

public class prefrence
{
    SharedPreferences sharedPreferences;
    public prefrence(Context context)
    {
        sharedPreferences = context.getSharedPreferences("myAppData", 0);
    }

    public boolean isFirstTime()
    {
        return sharedPreferences.getBoolean("first", true);
    }

    public void setFirstTime(boolean b)
    {
        sharedPreferences.edit().putBoolean("first", b).commit();
    }

}

and check that it is first time or not like this:

if (new preference(context).isFirstTime()) {
    showSplash();
    new preference(context).setFirstTime(false);
}
Marco Luongo
  • 397
  • 4
  • 13
faraz khonsari
  • 1,924
  • 1
  • 19
  • 27