[Android-development] Android Splash Screen

Ben Lau xbenlau at gmail.com
Fri Dec 18 20:38:39 CET 2015


haha, ok.

By the way, I just found that this method can not eliminate flicker
completely. Sometime it may happen. But I can not find out the reason /
step to reproduce. (Tested with Android 6.0 on nexus 5)

On 16 December 2015 at 20:54, Liang Jian <jianliang79 at gmail.com> wrote:

>     Thank you, I'll try this method When I have enough time :-)
>
> On Tue, Dec 15, 2015 at 9:43 PM, Ben Lau <xbenlau at gmail.com> wrote:
>
>> Hi Liang Jian,
>>
>> May be we could avoid this problem with a more simple way. I have
>> performed an experiment:
>>
>> 1. Create a custom theme and set windowBackground to splash.xml
>> 2. splash.xml is a white background image plus a Qt logo
>> 3. Set android.app.splash_screen_drawable to splash.xml
>> 4. Load a QML scene with white background only
>>
>> In this condition, the screen flicker won't be happen. I will only see
>> the Qt logo disappear.
>>
>> Then I changed to load a more complex scene, the screen flicker will
>> happen obviously.
>>
>> Therefore, I made an assumption that screen flicker may happen when there
>> are too many things to draw on startup (Construction of QtSurface). So we
>> may avoid it by showing a pure color image background first. Then show the
>> rest of content by fade-in animation.
>>
>> It seems to be working well on my Nexus 5.
>>
>> Here is my code:
>>
>> quickandroid/main.qml at DEV ยท benlau/quickandroid
>> <https://github.com/benlau/quickandroid/blob/DEV/examples/quickandroidexample/main.qml>
>>
>>
>>
>>
>>
>>
>> On 3 November 2015 at 23:11, Liang Jian <jianliang79 at gmail.com> wrote:
>>
>>>     Hi Ben Lau,
>>>     After some investigation I found the flicker was mainly caused by
>>> two reason:
>>>
>>>     1) When we show the QQuickView, qt will create a platform window for
>>> it, it is in fact a android SurfaceView, in QtActivityDelegate.createSurface()
>>> before the first QtSurface(which extends SurfaceView) was created qt will
>>> reset window's background drawable to the 'windowBackground' of the current
>>> theme, but the custom theme with the background image we want has been
>>> replaced by a system defined theme in QtActivity.onCreate().  I try to
>>> remove the code which reset window's background drawable and rebuild
>>> qt, but the flicker was still there which is caused by the following reason.
>>>
>>>     2) After the SurfaceView was created and before qt create EGL
>>> surface from it the screen will be black even if I set a  background color
>>> to this SurfaceView object. After some googling I found this:
>>> http://stackoverflow.com/questions/8772862/surfaceview-flashes-black-on-load/12636285#12636285
>>>     It seems that the flicker is unavoidable unless we use the dirty
>>> trick described in the post.
>>>
>>>     It is too complex for me to submit a patch to fix this issue :-(
>>>
>>> On Mon, Nov 2, 2015 at 7:34 PM, Ben Lau <xbenlau at gmail.com> wrote:
>>>
>>>> Hi Liang Jain,
>>>>
>>>> It will be great if you can find out the problem. Moreover, I think Qt
>>>> dev team may also consider to remove their own splash screen support which
>>>> is quite meaningless. They just not to clear window background during
>>>> onCreate() will be helpful
>>>>
>>>> On 1 November 2015 at 21:20, Liang Jian <jianliang79 at gmail.com> wrote:
>>>>
>>>>>      Hi Ben Lau,
>>>>>      You are right, with both methods applied the flicker will be
>>>>> minimal. I think now the flicker may be related to the creation of EGL
>>>>> surface, I will do more investigation into it.
>>>>>
>>>>> On Sun, Nov 1, 2015 at 9:05 PM, Ben Lau <xbenlau at gmail.com> wrote:
>>>>>
>>>>>> Hi Liang Jian,
>>>>>>
>>>>>> I mean to mix your method (custom AndroidStyle) together with
>>>>>>  android.app.splash_screen_drawable. It should have no impact for splash
>>>>>> screen loading time. It can be shown immediately after clicked to start the
>>>>>> application.
>>>>>>
>>>>>> However, for the flicker problem,yes , it still exists. But I think
>>>>>> it is less obvious then custom AndroidStyle only. I need to be focused on
>>>>>> screen change to discover the flicker.
>>>>>>
>>>>>> From my understanding, the splash screen change process can be
>>>>>> divided into 3 steps:
>>>>>>
>>>>>> 1. Render window background and title bar according to theme.
>>>>>>
>>>>>> 2. QtActivity.onCreate(Bundle)
>>>>>>
>>>>>> If android.app.splash_screen_drawable is set, it will render the
>>>>>> drawable. Otherwise, it will clear window background to #ff000000.
>>>>>>
>>>>>> 3. QQmlEngine loads the first scene and start rendering.
>>>>>>
>>>>>> If your don't set android.app.splash_screen_drawable, both of step 2
>>>>>> and 3 will first render a black screen, but their timing are different.
>>>>>> Step 3 is short and less obvious.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On 1 November 2015 at 20:36, Liang Jian <jianliang79 at gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>>     To Ben Lau: I have tried this method in the past, but that will
>>>>>>> also cause the flicker issue, and the most important is: with this method,
>>>>>>> It will take very long time before the splash screen show up after I click
>>>>>>> to start the app.
>>>>>>>
>>>>>>> On Sun, Nov 1, 2015 at 2:25 PM, Ben Lau <xbenlau at gmail.com> wrote:
>>>>>>>
>>>>>>>>
>>>>>>>> I have a suggestion. Based on the method from Liang Jian. Add the
>>>>>>>> following line to AndroidManifest.xml:
>>>>>>>>
>>>>>>>>             <meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/icon"/>
>>>>>>>>
>>>>>>>>
>>>>>>>> The "android:resource" should point to the same file like your
>>>>>>>> MyAndroidStyle.
>>>>>>>>
>>>>>>>> Will that fix the problem?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On 1 November 2015 at 09:40, Liang Jian <jianliang79 at gmail.com>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>>     I think we have encountered the same problem, the flicker I
>>>>>>>>> have mentioned is the black screen between splash screen and the first qml
>>>>>>>>> page :-)
>>>>>>>>>
>>>>>>>>> On Fri, Oct 30, 2015 at 11:23 PM, Bruno Tezine <btezine at gmail.com>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> Hi Liang Jian,
>>>>>>>>>> Thank you for your response.
>>>>>>>>>> I already tried to use this approach. You complain about a
>>>>>>>>>> flicker, but what about the black screen between the splash and the first
>>>>>>>>>> qml page?
>>>>>>>>>> I don't know if this happened with you, but under my tests, the
>>>>>>>>>> splash screen appears ok, but then the screen goes black for a while until
>>>>>>>>>> the main qml page is loaded.
>>>>>>>>>> Does it happen with you?
>>>>>>>>>> Kind regards,
>>>>>>>>>>    Bruno.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> 2015-10-30 12:11 GMT-02:00 Liang Jian <jianliang79 at gmail.com>:
>>>>>>>>>>
>>>>>>>>>>>      According to my experience, the best way to show splash
>>>>>>>>>>> screen in qt-android is to use a custom android theme and set its
>>>>>>>>>>> android:windowBackground. In this way the splash screen will show instantly
>>>>>>>>>>> after you click to launch your app. But unfortunately there is an annoying
>>>>>>>>>>> bug about this method, please refer to
>>>>>>>>>>> https://bugreports.qt.io/browse/QTBUG-43558
>>>>>>>>>>>
>>>>>>>>>>> On Thu, Oct 29, 2015 at 9:06 PM, Bruno Tezine <btezine at gmail.com
>>>>>>>>>>> > wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Hi,
>>>>>>>>>>>> How can I create a splash screen for Android using Qt (without
>>>>>>>>>>>> widgets)?
>>>>>>>>>>>> I don't know if it's possible. The idea is to present a splash
>>>>>>>>>>>> screen(image) immediately while the first qml page is loading. No timers
>>>>>>>>>>>> involved.
>>>>>>>>>>>> I have read several samples, but none seems to fit. Let me
>>>>>>>>>>>> explain:
>>>>>>>>>>>>
>>>>>>>>>>>> 1) http://doc.qt.io/qt-5/qtquick-window-example.html
>>>>>>>>>>>> --This example uses a timer. It doesn't display a splash while
>>>>>>>>>>>> the app is still loading the first screen.
>>>>>>>>>>>>
>>>>>>>>>>>> 2)
>>>>>>>>>>>> http://stackoverflow.com/questions/5486789/how-do-i-make-a-splash-screen
>>>>>>>>>>>> --It explains how to create splash screens using two
>>>>>>>>>>>> approaches. One using an Activity and other using a theme style. The first
>>>>>>>>>>>> approach uses a timer and delays the app load. The second quickly display a
>>>>>>>>>>>> splash, but after it disappears, the screen goes black while loading the
>>>>>>>>>>>> first qml page.
>>>>>>>>>>>>
>>>>>>>>>>>> Is it possible?
>>>>>>>>>>>> Thank you,
>>>>>>>>>>>>    Bruno.
>>>>>>>>>>>>
>>>>>>>>>>>> _______________________________________________
>>>>>>>>>>>> Android-development mailing list
>>>>>>>>>>>> Android-development at qt-project.org
>>>>>>>>>>>> http://lists.qt-project.org/mailman/listinfo/android-development
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> Android-development mailing list
>>>>>>>>> Android-development at qt-project.org
>>>>>>>>> http://lists.qt-project.org/mailman/listinfo/android-development
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/android-development/attachments/20151219/f14fcaa3/attachment.html>


More information about the Android-development mailing list