Skip to content

Instantly share code, notes, and snippets.

@dlfinis
Last active August 29, 2015 14:11
Show Gist options
  • Save dlfinis/ed29b7fd43f9792acb54 to your computer and use it in GitHub Desktop.
Save dlfinis/ed29b7fd43f9792acb54 to your computer and use it in GitHub Desktop.
Create a Splash Activity with Handler
package com.app.splash;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import java.util.Timer;
import java.util.TimerTask;
public class SplashActivity extends Activity {
// Splash screen timer
private static int SPLASH_TIME_OUT = 3000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
new Handler().postDelayed(new Runnable() {
/*
* Showing splash screen with a timer. This will be useful when you
* want to show case your app logo / company
*/
@Override
public void run() {
// This method will be executed once the timer is over
// Start your app main activity
Intent i = new Intent(SplashActivity.this, MainActivity.class);
startActivity(i);
// close this activity
finish();
}
}, SPLASH_TIME_OUT);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment