How To Create Splash Screen In Android Studio Java Code

 

 

 

Create Splash Screen In Android Studio Java Code. Please don't forget to Like, Share, Comment and Subscribe to our Techno Vedant Channel for more videos.

Products I Use For Making Videos:
Mic: https://amzn.to/2sItJ8P
Tripod: https://amzn.to/2OKuBlF
Camera: https://amzn.to/2Rhfimc
Laptop: https://amzn.to/2Lis1kV
LED Tubelight: https://amzn.to/2RmEwQ2
Web Hosting Link: https://www.hostinger.in/vedant



SplashActivity.java

    import androidx.appcompat.app.AppCompatActivity;


    import android.content.Intent;

    import android.os.Bundle;

    import android.view.Window;

    import android.view.WindowManager;


    public class SplashActivity extends AppCompatActivity {


        @Override

        protected void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);


            Window window = getWindow() ;


            window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

            setContentView(R.layout.activity_splash);




            Thread splashTread = new Thread(){


                @Override

                public void run() {

                    try {

                        sleep(3000);

                        startActivity(new Intent(getApplicationContext(),MainActivity.class));

                        finish();

                    } catch (InterruptedException e) {

                        e.printStackTrace();

                    }


                    super.run();

                }

            };


            splashTread.start();





        }


    }


activity_splash

    <?xml version="1.0" encoding="utf-8"?>

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

        xmlns:app="http://schemas.android.com/apk/res-auto"

        xmlns:tools="http://schemas.android.com/tools"

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        android:orientation="vertical"

        tools:context=".SplashActivity">


        <ImageView

            android:layout_width="match_parent"

            android:layout_height="300dp"

            android:src="@drawable/logo"

            android:scaleType="centerCrop"

            android:padding="50dp"

            android:layout_marginTop="220dp"/>

        <ProgressBar

            android:layout_width="220dp"

            android:layout_height="10dp"

            android:layout_gravity="center_horizontal"

            style="?android:attr/progressBarStyleHorizontal"

            android:max="100"

            android:indeterminate="true"

            android:progress="0"

            android:layout_marginTop="100dp"


            />



    </LinearLayout> 

AndroidManifest.xml

<activity android:name=".MainActivity"></activity>
<activity android:name=".SplashActivity">

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />


                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>

        </activity>

Android App Gives 2 App Icons

1. Open your app AndroidManifest.xml
2. At the bottom you will find this code.

      <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
      </intent-filter>

3. Delete this code.

Leave a Comment