public class SplashActivity extends Activity
{
private static final long DELAY = 3000;
private boolean scheduled = false;
private Timer splashTimer;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
splashTimer = new Timer();
splashTimer.schedule(new TimerTask()
{
@Override
public void run()
{
SplashActivity.this.finish();
startActivity(new Intent(SplashActivity.this, MainActivity.class));
}
}, DELAY);
scheduled = true;
}
@Override
protected void onDestroy()
{
super.onDestroy();
if (scheduled)
splashTimer.cancel();
splashTimer.purge();
}
}