ActivitySplashScreen.java :  » SMS » sms2air » de » crashsource » sms2air » gui » Android Open Source

Android Open Source » SMS » sms2air 
sms2air » de » crashsource » sms2air » gui » ActivitySplashScreen.java
package de.crashsource.sms2air.gui;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import de.crashsource.sms2air.R;

/**
 * 
 * @author Fabian Mueller, .crashsource, 2010
 * 
 */
public class ActivitySplashScreen extends Activity {
  
  protected boolean active = true;
  protected int splashTime = 1000;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash_screen);
    
    final Context context = this.getApplicationContext();

    // thread for displaying the SplashScreen
    Thread splashThread = new Thread() {
      @Override
      public void run() {
        try {
          int waited = 0;
          while (active && (waited < splashTime)) {
            sleep(100);
            if (active) {
              waited += 100;
            }
          }
        } catch (InterruptedException e) {
          // do nothing
        } finally {
          finish();
          startActivity(
              new Intent(context, ActivityMainScreen.class));
        }
      }
    };
    splashThread.start();
  }
  
  @Override
  public boolean onTouchEvent(MotionEvent event) {
      if (event.getAction() == MotionEvent.ACTION_DOWN) {
          active = false;
      }
      return true;
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.