Wednesday, 17 June 2015

SPLASH SCREEN


package com.example.shopus;
//change your package name here

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Window;
import android.view.WindowManager;

public class Splash extends Activity {

   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);

// the below two lines is for Full screen in device

       requestWindowFeature(Window.FEATURE_NO_TITLE);
       getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

//link with xml file
       
       setContentView(R.layout.activity_splash);
       
           
       Thread timer=new Thread(){
       
       public void run(){
           
       
               try {

// 4000 means 4,000 milliseconds.You can change this time

                   sleep(4000);
               } catch (InterruptedException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
               }
               finally{
// here change home to activity which you want app to proceed to
                   Intent i=new Intent(Splash.this,Home.class);
                   startActivity(i);
                   
               }
           
           
           
       }
       };
       timer.start();
   }

// the below is  crucial part.This makes the Activity the true definition of //splash screen
   @Override
   protected void onPause() {
       // TODO Auto-generated method stub
       super.onPause();
       finish();
       
   }

   

}         


No comments:

Post a Comment