Created
September 13, 2016 09:29
-
-
Save MensObscura/83665d4432e2fab17e235f173c488611 to your computer and use it in GitHub Desktop.
This file contains 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.graphics.Color; | |
import android.os.Build; | |
import android.os.Bundle; | |
import android.os.Handler; | |
import android.view.View; | |
import android.view.WindowManager; | |
public class SplashActivity extends Activity { | |
// Splash screen timer | |
private static int SPLASH_TIME_OUT = 2000; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_splash); | |
getWindow().getDecorView().setSystemUiVisibility( | |
View.SYSTEM_UI_FLAG_LAYOUT_STABLE | |
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | |
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); | |
getWindow().setStatusBarColor(Color.TRANSPARENT); | |
} | |
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 next Activity | |
startActivityForResult(new Intent(context, LoadStuffActivity.class), 0); | |
} | |
}, SPLASH_TIME_OUT); | |
} | |
@Override | |
protected void onStart() { | |
super.onStart(); | |
setVisible(true); | |
} | |
@Override | |
public void onActivityResult(int requestCode, int resultCode, Intent data) { | |
// when the next activity had done his stuff | |
finish(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment