Example : How to create a Splash Screen for an Android App/Activity using XML and Android Java.
AndroidManifests.xml file
------------------------------
[Set .SplashScreenActivity.xml file as Top in Activity tag with --- contents]
activity_splash_screen.xml
------------------------------
SplashScreenActivity.java
------------------------------
package com.rkm.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class SplashScreenActivity extends AppCompatActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
Intent x= new Intent(SplashScreenActivity.this, MainActivity.class);
new Handler().postDelayed(new Runnable()
{
@Override
public void run()
{
startActivity(x);
finish();
}
},4000);
}
}
0 Comments