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 ExampleIn 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). activity_main.xmlCreate an activity_welcome.xml file and add the following code. It is used for the layout of slider. activity_welcome.xmlNow create the layout for the welcome sliders as welcome_slide1.xml and welcome_slide2.xml in layout directory. welcome_slide1.xmlwelcome_slide2.xmlcolors.xmlstrings.xmldimens.xmlCreate 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. PrefManager.javaIn the WelcomeActivity.java class file, add the following code. In this class, we are performing the following tasks:
WelcomeActivity.javaIn the MainActivity.java class, add the following code. This class checks the state returned by the SharedPreferences. MainActivity.javaAndroidMenifest.javaOutput: Next TopicRecyclerView List |