Advertisement
Guest User

Untitled

a guest
Apr 10th, 2011
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.08 KB | None | 0 0
  1. package walk.me;
  2.  
  3. import android.app.Activity;
  4. import android.content.Intent;
  5. import android.graphics.Bitmap;
  6. import android.graphics.BitmapFactory;
  7. import android.os.AsyncTask;
  8. import android.os.Bundle;
  9. import android.widget.ImageView;
  10. import android.widget.LinearLayout;
  11.  
  12. public class Splasher extends Activity {
  13.    
  14.    
  15.     @Override
  16.     protected void onCreate(Bundle savedInstanceState) {
  17.         // TODO Auto-generated method stub
  18.         super.onCreate(savedInstanceState);
  19.         setContentView(R.layout.splash);
  20.         new SplashOperation().execute("");
  21.  
  22.     }
  23.  
  24.  
  25.     @Override
  26.     protected void onPause() {
  27.         // TODO Auto-generated method stub
  28.         super.onPause();
  29.     }
  30.  
  31.     @Override
  32.     protected void onResume() {
  33.         // TODO Auto-generated method stub
  34.         super.onResume();
  35.     }
  36.  
  37.    
  38.     private class SplashOperation extends AsyncTask<String, Void, String> {
  39.  
  40.         public LinearLayout layout= (LinearLayout)findViewById(R.id.splash);
  41.         public int imgSplash[]=
  42.         {R.drawable.a1,R.drawable.a2,R.drawable.a3, R.drawable.a4,
  43.         R.drawable.a5,R.drawable.a6,R.drawable.a7,R.drawable.a8,R.drawable.a9,
  44.         R.drawable.a10,R.drawable.a11,R.drawable.a12};
  45.         public int timer=0;
  46.         @Override
  47.         protected String doInBackground(String... params) {
  48.            
  49.             Thread splashThread = new Thread()
  50.             {
  51.                 public void run()
  52.                 {
  53.                    
  54.                     int timer=0;
  55.                     try
  56.                     {
  57.                         while(timer <= 2000)
  58.                         {
  59.                            
  60.                             sleep(200);
  61.                             timer = timer + 1000;
  62.                         }
  63.                         startActivity(new Intent("walk.me.CLEARSCREEN"));
  64.                     } catch (InterruptedException e) {
  65.                         // TODO Auto-generated catch block
  66.                         e.printStackTrace();
  67.                     }
  68.                     finally
  69.                     {
  70.                         finish();
  71.                     }
  72.                 }
  73.             };
  74.             splashThread.start();
  75.        
  76.             return null;
  77.            
  78.         }
  79.  
  80.         @Override
  81.         protected void onPostExecute(String result) {
  82.            
  83.         }
  84.  
  85.        
  86.         @Override
  87.         protected void onPreExecute() {
  88.    
  89.         @Override
  90.         protected void onProgressUpdate(Void... values) {
  91.           new Runnable(){
  92.  
  93.             @Override
  94.             public void run() {
  95.             layout.setBackgroundResource(imgSplash[timer]);
  96.             layout.invalidate();
  97.             }
  98.           }.run();
  99.           }
  100.          }
  101.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement