Android splash screen are normally used to show user some kind of progress before the app loads completely. Some people uses splash screen just to show case their app / company logo for a couple of second. Unfortunately in android we don’t have any inbuilt mechanism to show splash screen compared to iOS. In this tutorial we are going to learn how to implement splash screen in your android application.The purpose of splash screen depends upon the app requirement.
In order to implement splash screen we are going to create a separate activity for splash and once it closes we launch our main activity.
1. Android Splash Screen Using Timer
1. Create a new project in Eclipse by navigating to File ⇒ New Android ⇒ Application Project and fill required details. (I kept my main activity name as MainActivity.java)
2. For Splash Screen we are creating a separate activity. Create a new class in your package and name it as SplashScreen.java
3. Open your your AndroidManifest.xml file and make your splash screen activity as Launcher activity.
4. Create a layout file for splash screen under res ⇒ layout folder. I named the layout file as activity_splash.xml. This layout normally contains your app logo or company logo.
5. Add the following code in SplashScreen.java activity. In this following code a handler is used to wait for specific time and once the timer is out we launched main activity.
2. Android Splash Screen When Making Network (http) Calls
1. Follow the same steps as above until creation of SplashScreen.java
2. After that the first step is add INTERNET permission in the manifest file as this app going to use internet. Open your AndroidManifest.xml file and add INTERNET permission above <application> tag
<uses-permission android:name="android.permission.INTERNET"/> |
3. Open your SplashScreen.java and add AsyncTask to make http calls. In this tutorial i am making an http call to get json and displayed on the log in screen. After fetching the json the data will be sent to MainActivity.javausing Intents.


Comments
Post a Comment