- packagecom.livrona.apps.justsikh.activity;
- importandroid.app.Activity;
- importandroid.content.Intent;
- importandroid.os.Bundle;
- importcom.livrona.andriod.commons.utils.Log;
- importcom.livrona.apps.justsikh.R;
- publicclass SplashScreen extends Activity {
- protectedboolean _active =true;
- protectedint _splashTime =2000;// time to display the splash screen in ms
- @Override
- publicvoid onCreate(Bundle savedInstanceState){
- Log.d("in : onCreate(..)");
- super.onCreate(savedInstanceState);
- setContentView(R.layout.splash_screen);
- // thread for displaying the SplashScreen
- Thread splashTread =newThread(){
- @Override
- publicvoid run(){
- try{
- int waited =0;
- while(_active &&(waited < _splashTime)){
- sleep(100);
- if(_active){
- waited +=100;
- }
- }
- }catch(InterruptedException e){
- // do nothing
- }finally{
- finish();
- // create the splash screen
- Log.d("in : start the Home Screen Activity(..)");
- // create the splash screen
- Intent intent =new Intent(SplashScreen.this, HomeScreen.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
- SplashScreen.this.startActivity(intent);
- }
- }
- };
- splashTread.start();
- }
- }
↧
How to create a Splash Screen in Android?
↧