Android Intro Slider

Android Intro Slider is used primarily to introduce the user to the application's main features. It also attracts users to know about the app and helps them. It is also called the android welcome screen and is used just after installation to guide the user on how to use the app.

It is used in these days in nearly all popular apps and games.

Intro slider should only be shown when any customer visits the app for the first time. If the user comes after that, he/she should be redirected directly to the home page. Soon you'll see how you can do it.

Hey, Developers ! In this tutorial we will see how to create an intro slider in any android application and only show it for the first time when any customer visits the application. After that, the user will be redirected to home page. 

We are showing the SKIP button to allow the user to skip the intro slider and if he wants to go directly to the home page. We also show dots that represent a particular slide, and depending on whether that slide is selected or de-selected, it will change. 

At first, we will create android application. Then, we will see how to build IntroSlider in the application.

Follow steps below to create new project. Please ignore the steps if you have already created a new application.

S. No. Steps
1 Open Android Studio.
2 Click on Start a new Android Studio Project then choose your project and select Empty Activity.
3 Write application name as IntroSlider after this write a package name you can write your own package name.
4 Select language Java. Select minimum SDK you need. However, we have selected 17 as minimum SDK. Then, click next button.
5 If you have followed above process correctly, you will get a newly created project successfully. However, you can also visit tutorial  to Create a New Project to know steps in detail.

Now, I'm going to show you how the files in the value folder look like at the end of the tutorial.

Click on res => values folder and open the color.xml file. And include the following code. This includes dot color when inactive / active, background color of each intro slide, toolbar color, status bar etc. 


<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>

<!-- Screens background color--> 
<color name="bg_screen1">#008577</color>
<color name="bg_screen2">#ce4007</color>
<color name="bg_screen3">#08abb6</color>
<color name="bg_screen4">#0677a5</color>

<!-- dots inactive colors --> 
<color name="dot_dark_screen1">#4c4c4c</color>
<color name="dot_dark_screen2">#4c4c4c</color>
<color name="dot_dark_screen3">#4c4c4c</color>
<color name="dot_dark_screen4">#4c4c4c</color>

<!-- dots active colors -->
<color name="dot_light_screen1">#e5e5e5</color>
<color name="dot_light_screen2">#e5e5e5</color>
<color name="dot_light_screen3">#e5e5e5</color>
<color name="dot_light_screen4">#e5e5e5</color>

<array name="array_dot_active">
<item>@color/dot_light_screen1</item>
<item>@color/dot_light_screen2</item>
<item>@color/dot_light_screen3</item>
<item>@color/dot_light_screen4</item>
</array>

<array name="array_dot_inactive"> 
<item>@color/dot_dark_screen1</item>
<item>@color/dot_dark_screen2</item>
<item>@color/dot_dark_screen3</item>
<item>@color/dot_dark_screen4</item>
</array>
</resources> 

Click on res => values folder and open dimens.xml file. And include the following code.


<?xml version="1.0" encoding="utf-8"?> 
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="fab_margin">16dp</dimen>
<dimen name="dots_height">30dp</dimen>
<dimen name="dots_margin_bottom">20dp</dimen>
<dimen name="img_width_height">200dp</dimen>
<dimen name="slide_title">30dp</dimen>
<dimen name="slide_desc">16dp</dimen>
<dimen name="desc_padding">40dp</dimen>
</resources> 

Click on res => values folder and open strings.xml file. And include the following code. This file includes all the strings that the project uses. 


<resources>
<string name="app_name">Intro Slider</string>
<string name="title_activity_welcome">Home</string>
<string name="next">NEXT</string>
<string name="appbar_scrolling_view_behavior" translatable="false">android.support.design.widget.AppBarLayout$ScrollingViewBehavior</string>
<string name="skip">SKIP</string>
<string name="start">GOT IT</string>
<string name="slide1_desc">A platform where you will get free study materials from beginning to advance levels...</string>
<string name="slide1_title">Welcome to UK Academe</string>
<string name="slide2_desc">Learn to develop mobile applications using popular programming languages like android, ios etc.</string>
<string name="slide2_title">Develop Mobile Applications</string>
<string name="slide3_desc">Learn to develop web applications using popular programming languages like javascript, html, css, angular etc.</string>
<string name="slide3_title">Develop Web Applications</string>
<string name="slide4_desc">Get some more interesting things on UK Academe....</string>
<string name="slide4_title">Want some more interesting stuffs?</string>
<string name="play_again_desc">To see the intro slider again, goto Settings -> apps -> intro slider -> clear data</string>
<string name="play_again">Play Again</string>
<string name="get_started">Get Started</string>
<string name="check_it_out">Check It Out</string>
</resources>

Click on res => values folder and open styles.xml file. And include the following code. This file includes the application theme style. This includes whether or not to show a status bar, toolbar color, status bar etc.


<resources>
 <!-- Base application theme. -->
 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
 <!-- Customize your theme here. -->
 <item name="colorPrimary">@color/colorPrimary</item>
 <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
 <item name="colorAccent">@color/colorAccent</item>
 <item name="windowActionBar">false</item>
 <item name="windowNoTitle">true</item>
 </style>

 <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

 <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

 <style name="AppThemes" parent="Theme.AppCompat.Light.DarkActionBar">
 <!-- Customize your theme here. -->
 <item name="colorPrimary">@color/colorPrimary</item>
 <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
 <item name="colorAccent">@color/colorAccent</item>
 </style>
 </resources>

This folder contains images used in the application. You can use your own images in the application.

Before starting to write code into the java files, I would like to remind you of one thing – when users visit the app, we only show intro slide for the first time. Now, the question is how would you detect the first time the user visits the app or not? Think a little about it.

SHARED PREFERENCE is the answer. ...... 

We're going to use shared preference to detect whether this is first time visit or not. Now, what you call the first visit depends on you. In this tutorial, I consider first visiting the home page as a first visit to the application. Did you get confused? OK ..... Let me get to the point straight.

We will display the intro slider until the user visits the homepage. Means that if you first start the application, you will see the intro slider. Close the application now without visiting the homepage. Again, you will see intro slides when you start the application. Now, this time after visiting homepage, close the application. After that, if you restart the application, you won't see intro slides. 

Click on src => main => java => com.ukacademe.introslider package and create PrefManager.java file into it. And include the following code. This file will contain code that can be used in the entire application. We are writing shared preference code into it.


package com.ukacademe.introslider;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by UKAcademe on 19/05/19.
 */
public class PrefManager {
    SharedPreferences pref;
    SharedPreferences.Editor editor;
    Context _context;

    // shared pref mode
    int PRIVATE_MODE = 0;

    // Shared preferences file name
    private static final String PREF_NAME = "ukacademe-intro";

    private static final String IS_FIRST_TIME_LAUNCH = "IsFirstTimeLaunch";

    public PrefManager(Context context) {
        this._context = context;
        pref = _context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
        editor = pref.edit();
    }

    public void setFirstTimeLaunch(boolean isFirstTime) {
        editor.putBoolean(IS_FIRST_TIME_LAUNCH, isFirstTime);
        editor.commit();
    }

    public boolean isFirstTimeLaunch() {
        return pref.getBoolean(IS_FIRST_TIME_LAUNCH, true);
    }

}
  

Now we're going to create the intro slides that we're going to show when the application starts. We're going to show 4 slides. We're going to show every slide below. Just paste the code into your project. In each slide, we show title of the slide, image, description and button to start using the feature shown in the slide. 

Click on res => layout folder and create intro_slide1.xml, intro_slide2.xml, intro_slide3.xml and intro_slide4.xml files into it. Then copy the code below and paste it into the respective file.


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/bg_screen1"
android:layout_height="match_parent"
android:layout_width="match_parent">

<LinearLayout 
android:gravity="center_horizontal"
android:id="@+id/linearLayout"
android:layout_centerInParent="true"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical">

<ImageView
android:layout_height="@dimen/img_width_height"
android:layout_width="@dimen/img_width_height"
android:src="@drawable/ukacademe"
android:tint="@android:color/background_light" />

<TextView
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:paddingLeft="@dimen/desc_padding"
android:paddingRight="@dimen/desc_padding"
android:text="@string/slide1_desc"
android:textAlignment="center"
android:textColor="@android:color/white"
android:textSize="@dimen/slide_desc" />

</LinearLayout>

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="49dp"
android:layout_marginTop="55dp"
android:text="@string/slide1_title"
android:textAlignment="center"
android:textColor="@android:color/white"
android:textSize="@dimen/slide_title"
android:textStyle="bold" />

</RelativeLayout>

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bg_screen2">

<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center_horizontal"
android:orientation="vertical">

<ImageView
android:layout_width="@dimen/img_width_height"
android:layout_height="@dimen/img_width_height"
android:src="@drawable/mobileappdevelopment"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:paddingLeft="@dimen/desc_padding"
android:paddingRight="@dimen/desc_padding"
android:text="@string/slide2_desc"
android:textAlignment="center"
android:textColor="@android:color/white"
android:textSize="@dimen/slide_desc"/>
 
</LinearLayout>

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:text="@string/slide2_title"
android:textAlignment="center"
android:textColor="@android:color/white"
android:textSize="@dimen/slide_title"
android:textStyle="bold"
android:padding="10dp"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"/>

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:text="@string/get_started"
android:layout_marginTop="38dp"
android:layout_below="@+id/linearLayout"
android:layout_alignParentEnd="true"/>
 
</RelativeLayout>

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bg_screen3">

<LinearLayout 
android:id="@+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center_horizontal"
android:orientation="vertical">

<ImageView
android:layout_width="@dimen/img_width_height"
android:layout_height="@dimen/img_width_height"
android:src="@drawable/webappdevelopment"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:paddingLeft="@dimen/desc_padding"
android:paddingRight="@dimen/desc_padding"
android:text="@string/slide3_desc"
android:textAlignment="center"
android:textColor="@android:color/white"
android:textSize="@dimen/slide_desc"/>

</LinearLayout>

<TextView android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:text="@string/slide3_title"
android:textAlignment="center"
android:textColor="@android:color/white"
android:textSize="@dimen/slide_title"
android:textStyle="bold"
android:gravity="center"/>

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:text="@string/get_started"
android:layout_marginTop="38dp"
android:layout_below="@+id/linearLayout"
android:layout_alignParentEnd="true"/>

</RelativeLayout>
  

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bg_screen4">

<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center_horizontal"
android:orientation="vertical">

<ImageView
android:layout_width="@dimen/img_width_height"
android:layout_height="@dimen/img_width_height"
android:src="@drawable/ukacademe"
android:tint="#f0f0f0"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:paddingLeft="@dimen/desc_padding"
android:paddingRight="@dimen/desc_padding"
android:text="@string/slide4_desc"
android:textAlignment="center"
android:textColor="@android:color/white"
android:textSize="@dimen/slide_desc"/>

</LinearLayout>
<TextView android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="60dp"
android:padding="10dp"
android:text="@string/slide4_title"
android:textAlignment="center"
android:textColor="@android:color/white"
android:textSize="@dimen/slide_title"
android:textStyle="bold"/>

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_below="@+id/linearLayout"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="38dp"
android:text="@string/check_it_out"/>

</RelativeLayout>
  

Now we're going to create an activity for intro slides.

Click on res => layout folder and create activity_welcome.xml file. And include the following code. This file is going to be used as the Welcome Activity layout.


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:showIn="@layout/activity_welcome">

<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout android:id="@+id/layoutDots"
android:layout_width="match_parent"
android:layout_height="@dimen/dots_height"
android:layout_alignParentBottom="true"
android:layout_marginBottom="@dimen/dots_margin_bottom"
android:gravity="center"
android:orientation="horizontal">

</LinearLayout>
<View android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_above="@id/layoutDots"
android:alpha=".5"
android:background="@android:color/white"/>

<Button
android:id="@+id/btn_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="@null"
android:text="@string/next"
android:textColor="@android:color/white"/>

<Button android:id="@+id/btn_got_it"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="@null"
android:text="@string/start"
android:textColor="@android:color/white"
android:visibility="gone"/>

<Button
android:id="@+id/btn_skip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="@null"
android:text="@string/skip"
android:textColor="@android:color/white"/>

</RelativeLayout>

Click on src => main => java => com.ukacademe.introslider package and create WelcomeActivity.java file into it. And include the following code.


package com.ukacademe.introslider;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

public class WelcomeActivity extends AppCompatActivity {

    private ViewPager viewPager;
    private MyViewPagerAdapter myViewPagerAdapter;
    private LinearLayout dotsLayout;
    private TextView[] dots;
    private int[] layouts;
    private Button btnSkip, btnNext;
    private PrefManager prefManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Checking for first time launch - before calling setContentView()
        prefManager = new PrefManager(this);
        if (!prefManager.isFirstTimeLaunch()) {
            launchHomeScreen();
            finish();
        }

        // Making notification bar transparent
        if (Build.VERSION.SDK_INT >= 21) {
            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        }

        setContentView(R.layout.activity_welcome);

        viewPager = (ViewPager) findViewById(R.id.view_pager);
        dotsLayout = (LinearLayout) findViewById(R.id.layoutDots);
        btnSkip = (Button) findViewById(R.id.btn_skip);
        btnNext = (Button) findViewById(R.id.btn_next);


        // layouts of all intro sliders
        // add few more layouts if you want
        layouts = new int[]{
                R.layout.intro_slide1,
                R.layout.intro_slide2,
                R.layout.intro_slide3,
                R.layout.intro_slide4};

        // adding bottom dots
        addBottomDots(0);

        // making notification bar transparent
        changeStatusBarColor();

        myViewPagerAdapter = new MyViewPagerAdapter();
        viewPager.setAdapter(myViewPagerAdapter);
        viewPager.addOnPageChangeListener(viewPagerPageChangeListener);

        btnSkip.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                launchHomeScreen();
            }
        });

        btnNext.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // checking for last page
                // if last page home screen will be launched
                int current = getItem(+1);
                if (current < layouts.length) {
                    // move to next screen
                    viewPager.setCurrentItem(current);
                } else {
                    launchHomeScreen();
                }
            }
        });
    }

    private void addBottomDots(int currentPage) {
        dots = new TextView[layouts.length];

        int[] colorsActive = getResources().getIntArray(R.array.array_dot_active);
        int[] colorsInactive = getResources().getIntArray(R.array.array_dot_inactive);

        dotsLayout.removeAllViews();
        for (int i = 0; i < dots.length; i++) {
            dots[i] = new TextView(this);
            dots[i].setText(Html.fromHtml("•"));
            dots[i].setTextSize(35);
            dots[i].setTextColor(colorsInactive[currentPage]);
            dotsLayout.addView(dots[i]);
        }

        if (dots.length > 0)
            dots[currentPage].setTextColor(colorsActive[currentPage]);
    }

    private int getItem(int i) {
        return viewPager.getCurrentItem() + i;
    }

    private void launchHomeScreen() {
        prefManager.setFirstTimeLaunch(false);
        startActivity(new Intent(WelcomeActivity.this, MainActivity.class));
        finish();
    }

    //	viewpager change listener
    ViewPager.OnPageChangeListener viewPagerPageChangeListener = new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            addBottomDots(position);

            // changing the next button text 'NEXT' / 'GOT IT'
            if (position == layouts.length - 1) {
                // last page. make button text to GOT IT
                btnNext.setText(getString(R.string.start));
                btnSkip.setVisibility(View.GONE);
            } else {
                // still pages are left
                btnNext.setText(getString(R.string.next));
                btnSkip.setVisibility(View.VISIBLE);
            }
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {

        }

        @Override
        public void onPageScrollStateChanged(int arg0) {

        }
    };

    /**
     * Making notification bar transparent
     */
    private void changeStatusBarColor() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);
        }
    }

    /**
     * View pager adapter
     */
    public class MyViewPagerAdapter extends PagerAdapter {
        private LayoutInflater layoutInflater;

        public MyViewPagerAdapter() {
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

            View view = layoutInflater.inflate(layouts[position], container, false);
            container.addView(view);

            return view;
        }

        @Override
        public int getCount() {
            return layouts.length;
        }

        @Override
        public boolean isViewFromObject(View view, Object obj) {
            return view == obj;
        }


        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            View view = (View) object;
            container.removeView(view);
        }
    }
}

This file contains view pager code that is responsible for swipeable viewing. It also creates the dots for each slide to be shown. 

We're going to design our homepage. If any user first visits this page, we would mark him as having successfully visited the application for the first time. We're not going to show them intro slider after that.

Click on res => layout => activity_main.xml file and include the following code.


<?xml version="1.0" encoding="utf-8"?>
 <android.support.design.widget.CoordinatorLayout xmlns:android=" http://schemas.android.com/apk/res/android" xmlns:app="
http://schemas.android.com/apk/res-auto" xmlns:tools="
http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity"> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/play_again_desc" />

<Button
android:id="@+id/btn_play_again"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/play_again" />

</LinearLayout>
</android.support.design.widget.CoordinatorLayout> 

Finally, Go to MainActivity.java file into it. and include the following code.

Note: If you want to see again the intro slider screen click on play again button in the application. Or you can clear the application data from settings and you can see again the intro slider screen.


package com.ukacademe.introslider;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.btn_play_again).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // We normally won't show the intro slider again in real app
                // but this is for testing
                PrefManager prefManager = new PrefManager(getApplicationContext());

                // make first time launch TRUE
                prefManager.setFirstTimeLaunch(true);

                startActivity(new Intent(MainActivity.this, WelcomeActivity.class));
                finish();
            }
        });
    }
}

Now, the last step is in androidmanifest file here we can define our welcome activity and main activity. So include the following code into your androidmanifest.xml file.

 


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ukacademe.introslider">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<activity android:name=".WelcomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"
android:label="@string/title_activity_welcome"
android:theme="@style/AppThemes"></activity> 
</application>

</manifest>

Congratulations! your IntroSlider App is completed just run it on your device or in emulator.