Search code examples
androidsplash-screen

How can i show my splash screen first without making in Mainacitivity


I made a splash screen class name Splash.class . I didnt make in mainacitivity so how i can I show this at first screen (Opening screen or first screen)

Manifest

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.LoginApp">
        <activity
            android:name=".second"
            android:exported="true"></activity>
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        </activity>
    </application>

</manifest>


Solution

  • change your manifest like this

    <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:supportsRtl="true"
            android:theme="@style/Theme.LoginApp">
            <activity
                android:name=".second"
                android:exported="true"></activity>
            <activity
                android:name="com.your.package.Splash" //put yout class here
                android:exported="true">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
    
            </activity>
        </application>
    
    </manifest>

    First time your android will run activity with category LAUNCHER, so change your activity class in category.LAUNCHER with your class (Splash.java)