I'm facing the splash screen issue on Android 7 and lower. It works fine on Android 7+ but on Android 7 and lower the app crashes as soon as it is opened, without a splash screen app is working fine. Any Solutions?
I have tried using different pngs and styles and color values but still the same issue.
MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState)
{
SplashScreen.show(this, true);
super.onCreate(savedInstanceState);
}
SplashActivity.java
public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
}
}
AndroidManifest.xml
....
<activity
android:name=".SplashActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true"
>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
....
The issue has been solved, basically what I did earlier was that I Placed splash_screen.png in the drawable folder which worked perfectly for Android 7+ but was causing problems for Android 7 and lower.
So I placed the same splash_screen.png in all mipmaps folders and referred to mipmaps as follows in the launch_screen.xml file.
android:src="@mipmap/launch_screen"
After that splash screen worked perfectly for all the versions. Thanks