Search code examples
javaandroidsplash-screenandroid-4.4-kitkatlandscape

why android splash screen is not showing in landscape orientation of kitkat & older devices?


I have added splash screen in my android app (which has android API level 14-26 target support) as follows:

In my AndroidManifest.xml

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

In styles.xml, the SplashTheme is defined as:

<style name="SplashTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">

        <item name="android:windowBackground">@drawable/splash_graphic</item>
        <item name="android:windowNoTitle">true</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="android:windowFullscreen">true</item>
        <item name="android:windowContentOverlay">@null</item>
    </style>

My splash_graphic.xml as follows:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <color android:color="@color/colorPrimary"/>
    </item>
    <item>
        <bitmap android:src="@drawable/my_logo" android:tileMode="disabled" android:gravity="center" />
    </item>
</layer-list>

And my Splash Activity as:

public class SplashActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        startActivity(new Intent(SplashActivity.this, ActivationActivity.class));
        finish();
    }
}

My strange problem is: The splash screen works OK in both Landscape and Portrait screen orientations on Lollipop and newer devices but it works only in Portrait screen orientation on Kitkat and pre-kitkat devices. How can I get it work for Landscape orientation too on kitkat and pre-kitkat devices too?


Solution

  • After so many hours of searching, I finally came to a solution for my strange problem, which is not a coding solution. This may sound little awkward, however, I want to share it just because it worked for me and I think it can be helpful for other people. So, here is my workaround:

    Caused By:

    This problem was being caused by the default home launcher app ,which manages apps showcasing in Landscape and Portrait screen orientation of devices [I observed the problem on 1. Huawei MediaPad T1 7.0 Tablet 2. Lenovo a-319 Rockstar and 3.Samsung Galaxy S Duos 7562 ]. But I did not observe any problem on any devices[Splash-screen worked on any screen orientations on 1. Samsung Galaxy J Max SM-T285YD Tab 2.Samsung J 7 Prime phone] that had Lollipop or newer android OSes.

    The Solution:

    So, I changed the default home launcher app on devices which had problem. EMUI launcher of Huawei MediaPad tab and Fly launcher of Lenovo a-319[I had rooted this device, so launcher is different than other Lenovo phones] were replaced with Google Now Launcher from google play, which now is not officially supported by google. As Samsung S Duos 7562 did not support Google Now Launcher, its TouchWiz launcher was replaced with Nova Launcher . After default home launcher app replacement, now, the problem is solved on all target devices.