Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to show a "quick tour" when first opening the app? [closed]

I do not know exactly how to explain that, but when many apps are first launched, usually the user can scroll through 3 or 4 screens that "preview"/"quick tour" the app before the user actually logs into the app. How can I achieve that in Android?

like image 969
Stephane Maarek Avatar asked Sep 29 '22 04:09

Stephane Maarek


1 Answers

You don't need a library. What you can do is use a ViewPager That has different screens explaining different parts of the app.

In order to make sure that this only runs once you can have the following code in your FirstRunActivity's onCreate() method:

boolean firstRun = getPreferences(Context.MODE_PRIVATE).getBoolean("firstRun", true);

        if (!firstRun) {
            Intent mainAppIntent = new Intent(getApplicationContext(), MainActivity.class);
            startActivity(mainAppIntent);
            finish();
            return;
        }

// Set up ViewPager and first run stuff

After the first run has been completed and the user is in the app, then you set firstRun in SharedPreferences to false like so:

getPreferences(Context.MODE_PRIVATE)
                        .edit()
                        .putBoolean("firstRun", false)
                        .commit();
like image 80
Andrew Orobator Avatar answered Oct 12 '22 22:10

Andrew Orobator