Home > General > Splash Screen in Android

Splash Screen in Android

If you wanted splash screen in Android apps, Splash screen will come first for few second then from splash screen main screen will lunch. How to use splash screen, how long you wanted to show splash screen in Android apps

R.layout.splash -> this is .xml layout, it will show how you wanted to show your splash screen.
startActivity(new Intent(SplashScreen.this, MainScreen.class)) – > Mainscreen will be your next screen you wanted to come automatically after splash screen.
CountDownTimer timer = new CountDownTimer(1000, 1000) -> splash screen will visible for 1 sec.


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;

public class SplashScreen extends Activity {
/** Called when the activity is first created. */
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);

CountDownTimer timer = new CountDownTimer(1000, 1000) {
@Override
public void onFinish() {
startActivity(new Intent(SplashScreen.this, MainScreen.class));
}
@Override
public void onTick(long arg0) {
// TODO Auto-generated method stub
}
};
timer.start();
}

@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
finish();
}
}

Advertisements
Categories: General
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: