How Do I Show A Splash Screen In Android?
I want to show a splash screen when my app loads up, this is my Java code: ImageView splash = (ImageView) this.findViewById(R.id.splashscreen); splash.postDelayed(new Runnable(){
Solution 1:
You can do as follows:
private static final int SPLASH_TIME_OUT = 2000;
private static final Handler mHandler = new Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
startActivity(new Intent(getApplicationContext(), YourActivity.class));
finish();
}
}, SPLASH_TIME_OUT);
}
Here activity_splash.xml
is your splash
Activity layout and YourActivity
is the Activity you're going to next.
Solution 2:
private ImageView splash;
splash = (ImageView)findViewById(R.id.splashscreen);
new Handler().postDelayed(new Runnable(){
@Override
public void run() {
splash.setVisibility(View.GONE);
}
}, 3000);
Try this.
Post a Comment for "How Do I Show A Splash Screen In Android?"