How to create Splash Screen in Android

by Saturday, March 03, 2012 0 comments
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.

 SplashScreen.java:

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();
}
}

karthik nagarajan

Androider

Welcome to Android-Action Blog. I’m a normal guy, who is passionate about Mobile Coding. Here I am writing about Android. Happy learning

0 comments:

Post a Comment