Search code examples
androidc++qtqmlqtandroidextras

Can't Hide a QtAndroid Splashscreen with QtAndroid::hideSplashScreen();


I am currently developing a Qt C++/QML app for android and I've come across an issue. By following the steps in this guide: HERE.

This produces a very clean and functional SplashScreen (natively I assume). However, It instructs me to use QtAndroid::hideSplashScreen(); to hide the splashscreen when all elements are loaded. This method just leaves me with a blank screen as shown below:

enter image description here

enter image description here

There are no error messages shown regarding the success/failure to display/hide this element. After "hiding" it, there is no view display (my view should be shown at this time.)

My method for hiding the splashscreen is as follows:

using namespace Esri::ArcGISRuntime;

CanfieldFairApp::CanfieldFairApp(QObject* parent /* = nullptr */):
    QObject(parent),
    m_map(new Map(Basemap::streetsNightVector(this), this))
{
    connect(m_mapView, SIGNAL(navigatingChangedEvent()), this, SLOT(navigatingChangedEvent()));

    connect(m_map, &Esri::ArcGISRuntime::Map::loadStatusChanged, this, [](Esri::ArcGISRuntime::LoadStatus loadStatus)
    {
        if (loadStatus == LoadStatus::Loaded)
        {
            QtAndroid::hideSplashScreen();
            qDebug() << "Map Loaded!";
        }
    });
}

As a result I do see "Map Loaded!" Called, but nothing appears.

Keep in mind, without a splashscreen, the Main View displays perfectly fine.

AppTheme.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppTheme" parent="@android:style/Theme.DeviceDefault.NoActionBar">
        <item name="android:windowBackground">@drawable/splash</item>
        <item name="android:statusBarColor">#ffffff</item>
    </style>
</resources>

Splash.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
    <item>
        <shape android:shape="rectangle" >
            <solid android:color="#ffffff"/>
        </shape>
    </item>    <item>
        <bitmap
            android:gravity="center"
            android:src="@drawable/app"/>
    </item>
</layer-list>

AndroidManifest.xml sections:

<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="Canfield Fair App" android:icon="@drawable/icon">
        <activity android:theme="@style/AppTheme" android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="Canfield Fair App" android:screenOrientation="unspecified" android:launchMode="singleTop">

<meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/splash"/>
<meta-data android:name="android.app.splash_screen_sticky" android:value="true"/>

Solution

  • The fix seems to be removing <item name="android:windowBackground">@drawable/splash</item> from AppTheme.xml.

    Tested on Qt 5.14.2 / Android.