I have empty Qt/QML android app and I am trying to display splash screen.
Without Splash screen implementation this screens are displayed:

Now I am following this example for splash screen which add the splash screen in the android manifest file. And this is the result I got:

My question is, Is it possible to avoid Screen number 1? Instead of screen 1, I want Splash screen to be displayed immediately when app is launched. Any suggestions are welcomed. Thanks in advance.
I think I found a solution for this problem thanks to this post.
Author of that post, for splash screens in Qt/QML android app wrote:
Basically, you could ignore any solution by C++/QML code only. Because they are started late.
I would like to add that, when author said "they are started late", I think it is because all of your Qt/QML android app is compiled at the end like .so (shared library). So when your app start, what happens behind is:
Now the solution to display splash screen(Steps from the post above):
Create template from QtCreator for your android app if you don't have created yet.
Create splash.xml inside android/res/drawable, like this
Create custom theme, apptheme.xml inside android/res/values, like this
Add this line in your activity tag in AndroidManifest.xmnl
android:theme="@style/AppTheme"
Also this line in AndroidManifest.xml, inside activity tag:
<meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/splash"/>
Now the rest is in your main.qml file. Set your Window/ApplicationWindow element as invisible at beginning(as I saw this will hold the splash screen), use Loader for your first page, and when its loaded, set the Window/ApplicationWIndow visible to true. This is my example:
Loader
{
id: loader
asynchronous: true
anchors.fill: parent
sourceComponent: MainScreen
{
width: root.width
height: root.height
Component.onCompleted:
{
root.isReady = true
}
}
}
In Qt5.15 you can select a Android native splash screen image in AndroidManifest.xml (in QtCreator)
Other option is to start your software with a simple and fast window: just a window, a image (async), a timer, and a loader for the rest of your software.
When the timer is activated (within 1-2 seconds), you can start the loader.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With