Qt on Android : Working example of a splash screen
-
#dominik.fehr, I also used the way you specified, it did work and show the splash screen, but the application still shows a black screen for around 4 seconds before showing the splash screen and then the application. apparently this splash is not a splash it is a part of the application.
Any Idea
Thanks -
#Baso
Also on 5.3.1 and it works perfectly with the AndroidManifest method posted by Larpon.Are you editing the right folder? Since everything gets overwritten, it sounds like you are editing the android output folder and not the soure folder.
Check if the project file has the line:
@ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android_build@
(Btw. since my project is quite old, the androidsource folder isnt called "android_build", but only "android". So check if the folder specified in the project file is the same, you use for your custom android files). -
[code]
#include "mainwindow.h"
#include <QApplication>
#include <QSplashScreen>
#include <QTimer>int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;QPixmap pixmap(":/images/splash.png"); QSplashScreen splash(pixmap); splash.show(); QTimer::singleShot(3000, &splash, SLOT(close())); QTimer::singleShot(3000, &w, SLOT(show())); return a.exec();
}
[/code]
This example work well but there is a big (for me) problem when I run the app in the Android device (no emulation).Before that the Splash Screen part, for a second the MainWindow showing the incon associated upper left. After start the Splash Screen and then the MainWindow.
The intial second of the MainWindow is deleterious.
I tried the following solution, but it does not work well at 100%
[code]
#include "mainwindow.h"
#include <QApplication>
#include <QSplashScreen>
#include <QTimer>int main(int argc, char *argv[])
{
QApplication a(argc, argv);QPixmap pixmap(":/images/splash.png"); QSplashScreen splash(pixmap); splash.show(); MainWindow w; QTimer::singleShot(3000, &splash, SLOT(close())); QTimer::singleShot(3000, &w, SLOT(show())); return a.exec();
}
[/code]If I run the app in my desktop I haven't problem.
Inside the MainWindow I have a Menu.
If I remove the Menu from MainWindow I haven't the problem.
-
In case you found that the action bar with your application name is shown together with your splash image. You may add this attribute to <activity> tag
@
android:theme="@android:style/Theme.Holo.Light.NoActionBar"
@ -
Thank you for the response but it doesn't resolve my problem.
if I add the following code:
@android:theme="@android:style/Theme.Holo.Light.NoActionBar"@
the splash screen is without action bar but also the next screen is without action bar.
The same result if I use:
@android:theme="@android:style/Theme.NoTitleBar"@
My application show the application screen without Title bar (ok) and after the next screen show the Title bar (perfect).
My problem is that the screen before splash screen (about 1 second) show the Title bar after it hide and show the Splash screen and after the screen with the title bar.
-
Hi,
FYI, I have written an article about how to create a splash screen with instant response and will not turn black:
Complete Guide to Making a Splash Screen for your QML Android Application — Medium
-
Hi,
FYI, I have written an article about how to create a splash screen with instant response and will not turn black:
Complete Guide to Making a Splash Screen for your QML Android Application — Medium
Hi @benlau
But how this works with different resolution Android Screens as in my case the Splash Screen is not same in all devices (either enlarged or bulged)
-
Hi @benlau
But how this works with different resolution Android Screens as in my case the Splash Screen is not same in all devices (either enlarged or bulged)
@Pradeep-P-N From the link:
"1. Prepare a splash screenIt is not recommended to use a single image as the splash screen. It will be scaled to fill up all the space. Make it as a drawable resource is easier to fit for all devices."
-
@Pradeep-P-N From the link:
"1. Prepare a splash screenIt is not recommended to use a single image as the splash screen. It will be scaled to fill up all the space. Make it as a drawable resource is easier to fit for all devices."
Hi @jsulm ,
Thank you, i found an other way and was able to solve it :)
cool :)
Thanks again for the support. -
Hi @jsulm ,
Thank you, i found an other way and was able to solve it :)
cool :)
Thanks again for the support.wanne share your solution?