Skip to content

Instantly share code, notes, and snippets.

@anncode1
Created November 28, 2015 02:10
Show Gist options
  • Save anncode1/7ee57630dfbac66dda23 to your computer and use it in GitHub Desktop.
Save anncode1/7ee57630dfbac66dda23 to your computer and use it in GitHub Desktop.
Android Manifest
<activity
android:name="SplashScreenActivity"
android:launchMode="singleTask" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="MainActivity"
android:launchMode="singleTask" >
</activity>
SplashScreenActivity.java
private static final long SPLASH_SCREEN_DELAY = 4000;
TimerTask task = new TimerTask() {
@Override
public void run() {
// Start the next activity
Intent mainIntent = new Intent().setClass(
SplashScreenActivity.this, MainActivity.class);
startActivity(mainIntent);
// Close the activity so the user won't able to go back this
// activity pressing Back button
finish();
}
};
// Simulate a long loading process on application startup.
Timer timer = new Timer();
timer.schedule(task, SPLASH_SCREEN_DELAY);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment