Introduction Slider Example (Launch very first time when app start)
It is a good idea to implement a welcome slider screen which introduces the major features of the app. In this slider, a brief introduction of the app can be given where the user can swipe through the sliders before launching the application (MainActivity or Home-page).
Android Introduction Slider Example
In this example, we will use SharedPreferences class that is used to keep the state whether the app is being launched the first time or not. If the app is launched for the very first time, then it displays sliders before launching the application otherwise launch MainActivity.
Create an activity_main.xml file in layout directory with following code (your UI).
Create an activity_welcome.xml file and add the following code. It is used for the layout of slider.
Now create the layout for the welcome sliders as welcome_slide1.xml and welcome_slide2.xml in layout directory.
Create a PrefManager.java class and add the following code. In the class, we use SharedPreferences class that keeps the preference name and a Boolean state true if the app is launched for the first time.
In the WelcomeActivity.java class file, add the following code.
In this class, we are performing the following tasks:
In the MainActivity.java class, add the following code. This class checks the state returned by the SharedPreferences.