Skip to content

Instantly share code, notes, and snippets.

@Krishan14sharma
Created December 12, 2014 07:41
Show Gist options
  • Save Krishan14sharma/f28e012ba9498b1d29d4 to your computer and use it in GitHub Desktop.
Save Krishan14sharma/f28e012ba9498b1d29d4 to your computer and use it in GitHub Desktop.
Splash Template
package com.dnn.zapbuild.sports.controller.activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.ActionBarActivity;
import com.dnn.zapbuild.sports.R;
/**@author zapbuild
* This is the launcher activity.Shows an image for SPLASH_TIME and then kills itself after passing
* the control.
*/
public class SplashActivity extends ActionBarActivity {
public static final int SPLASH_TIME=2*1000;
Handler mhandler;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
mhandler=new Handler();
mhandler.postDelayed(new Runnable() {
@Override
public void run() {
Intent in = new Intent(SplashActivity.this, MainActivity.class);
startActivity(in);
finish();
}
}, SPLASH_TIME);
}
@Override
public void onBackPressed() {
// There is no back pressing allowed on this activity.
}
@Override
protected void onDestroy() {
super.onDestroy();
if(mhandler!=null)
{
mhandler.removeCallbacksAndMessages(null);
mhandler=null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment