-4

Iam trying to add Splash screen to my existing Android Project, which is not MainActivity.Java, but by default Android Studio is executing MainActivity.Java first, So I want to change the Activity Priority so that my SplashActivity.Java will execute first and later Activity's will follow after the Splash Screen.

Kajal K
  • 7
  • 1
  • 5

4 Answers4

3

Make splash activity your launcher activity instead of Main Activity in Android Manifest.

 <activity
        android:name=".ui.splash.SplashActivity"
        android:screenOrientation="portrait"
        android:theme="@style/SplashTheme">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
1

modify your AndroidManifest.xml like this

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.circlefil.reactivetrip">

    <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/AppTheme">
        <activity android:name=".MainActivity"/>
        <activity android:name=".SplashActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

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

</manifest>
sanemars
  • 767
  • 5
  • 18
1

You need to add IntentFilter in you splash screen activity and from splash screen activity you have to link your main activity using Intent.

Add following code to your splash screen activity.

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

How ever keeping an entire activity is not the best way to create splash screen. See this for more info: Here

Kaushal28
  • 5,377
  • 5
  • 41
  • 72
1

To Start activity first you need to make it Launcher Activity in AndroidManifest.xml file.

<activity
        android:name=".StartingActivityName">

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

    </activity>
yatin deokar
  • 730
  • 11
  • 20