Skip to content
  • Home

A Computer Engineer

Just another geek.

splash page

Add the splash page to your android application

June 26, 2015June 26, 2015dakshbhattLeave a comment

If you want to cache any background data in your app from the internet then you should use splash page when the app opens.  It will engage the user for a few seconds while your data is downloaded in the background. Otherwise the splash page can irritate users. Check out more discussion about the pros/cons of the splash screen here.

splash page screen
splash page when app launched

Now about the implementation of the splash page in android app. It is very easy to implement and it takes about 2-3 minutes to add.

We will go step by step

1. Add your splash page activity to the manifest.xml file with the following attributes.

<activity
  android:name=".SplashPageActivity"
  android:label="Splash Activty" >
  <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
</activity>

The above code sets your splash page activity as the launcher activity of the app, so when you open the app splash page activity will be open first. Make sure that you remove the same intent filter from any other activity to prevent from creating multiple entry point to the app.

2. Create the layout for splash page. Generally all the professional app has their logo and tag line in the splash page. So create your layout for the splash page in the res -> layout folder. The example of simple splash page displayed here.

activity_splash_page.xml

<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:context=".SplashPageActivity"
  android:background="#393939">

  <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:src="@drawable/ic_launcher" />

</RelativeLayout>

3. Now we create SplashPageActivity with the login of splash page. It will display the splash page for 3 seconds or the duration in which the background data is downloaded and then open the next activity of your app. Here I have login activity to open.

SplashPageActivity.java

public class SplashPageActivity extends Activity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
    new Handler().postDelayed(new Runnable(){
      @Override
      public void run() {
        Intent login = new Intent(SplashPageActivity.this, LoginActivity.class);
        startActivity(login);
        finish();
      }
    }, 2000);
  }
}

Androidactivity, android, launcher, logo, splash page

Android Functions

Ready to use Android Functions for your Android app! Android Functions

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 14 other subscribers

Blog Stats

  • 274,134 hits

Recent Posts

  • Add text on video programmatically in Android using Media3 Transformer APIs September 23, 2024
  • SharedPreferences in Android Kotlin (with How to Remember User Login/Session Example) February 11, 2020
  • Different colors for selected tab in BottomNavigationView in Android Kotlin(Programmatically) January 13, 2020
  • Populate and manipulate AutoCompleteTextView in Android August 4, 2019
  • Open chat page in Whatsapp for given number in Android July 5, 2019

Top Posts & Pages

  • Turn on and turn off flash light programmatically in Android

About Me

profile for dakshbhatt21 at Stack Overflow, Q&A for professional and enthusiast programmers
Follow A Computer Engineer on WordPress.com

Categories

  • Android
  • Informative
  • Java
  • Javascript
  • Kotlin
  • PHP
  • Python
  • Uncategorized
  • VB.Net
Blog at WordPress.com.
  • Subscribe Subscribed
    • A Computer Engineer
    • Already have a WordPress.com account? Log in now.
    • A Computer Engineer
    • Subscribe Subscribed
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
 

Loading Comments...