top of page
splash.xml
Anchor 1

 

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@drawable/splash_image"

android:orientation="vertical">

 

</LinearLayout>

SplashScreen activity
Anchor 2

 

package com.example.main.projectstructure;

 

import android.app.Activity;

import android.content.Intent;

import android.os.Bundle;

 

/**

* Created by vamsikrishna on 12-Feb-15.

*/

public class SplashScreen extends Activity {

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        // TODO Auto-generated method stub

        super.onCreate(savedInstanceState);

        setContentView(R.layout.splash);

 

        Thread timerThread = new Thread(){

            public void run(){

                try{

                    sleep(3000);

                }catch(InterruptedException e){

                    e.printStackTrace();

                }finally{

                    Intent intent = new Intent(SplashScreen.this,MainActivity.class);

                    startActivity(intent);

                }

            }

        };

        timerThread.start();

    }

 

    @Override

    protected void onPause() {

        // TODO Auto-generated method stub

        super.onPause();

        finish();

    }

 

}

Anchor 3
AndroidManifest.xml

 

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.example.main.projectstructure" >

 

<application

android:allowBackup="true"

android:icon="@mipmap/ic_launcher"

android:label="@string/app_name"

android:theme="@style/AppTheme" >

 

<activity

android:name=".SplashScreen"

android:label="@string/app_name" >

<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/app_name" >

<intent-filter>

<action android:name="com.example.main.projectstructure.MAINACTIVITY" />

 

<category android:name="android.intent.category.DEFAULT" />

</intent-filter>

</activity>

</application>

 

</manifest>

Special thanks for the use of thier free code: http://www.coderefer.com/android-splash-screen-example-tutorial/

bottom of page