Created
February 6, 2013 15:06
-
-
Save astagi/4723136 to your computer and use it in GitHub Desktop.
Extend this class to transofrm your activity in a splash screen activity for Android!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.os.Handler; | |
public class SplashScreenActivity extends Activity { | |
private Handler splashTimeout = new Handler(); | |
private Class<?> cls; | |
private long time; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
} | |
public void setActivityTime(Class<?> cls, long time) { | |
this.cls = cls; | |
this.time = time; | |
} | |
@Override | |
protected void onResume() { | |
super.onResume(); | |
splashTimeout.postDelayed(new Runnable() { | |
@Override | |
public void run() { | |
Intent intent = new Intent(SplashScreenActivity.this, cls); | |
startActivity(intent); | |
SplashScreenActivity.this.finish(); | |
} | |
}, time); | |
} | |
@Override | |
public void onDestroy() { | |
super.onDestroy(); | |
if(splashTimeout != null) | |
splashTimeout.removeMessages(0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment