[Android-development] QML Timer stops if Android Activity enters OnPause

Michael Leithner michael.leithner at gmail.com
Thu Mar 5 23:59:10 CET 2020


Hm... I don't tried with QTimer for iOS,
because AdMob for iOS works without any flaws.

But what I do know is, that iOS completely kills the app if it's closed
(and memory is needed). So do Qt for Desktop and Android if the app is put
into background (through home button or switching to another app)

Although I encountered the problem, if I just Show an AdMob Interstitial
app on top of my Main Activity... dunno about the concrete Implementation,
but either is another Activity put on top of my main or they are switched
so that the Interstitial is in Background.
Or it could be, that the ad is just shown in an overlay webview?

Anyway, as soon as I show the ad, my Timer stops working, only for Android.



Am Do., 5. März 2020 um 16:39 Uhr schrieb Jason H <jhihn at gmx.com>:

> I'm suspicous of QTimer working on iOS like you think it does.
> I have encountered some expected behavior for about 20 seconds after the
> app is in the background, but after that all hell breaks lose.
> Like, any listen sockets have to be closed and re-listened. I would expect
> the timer to be the same way. iOS does not specify 20 seconds anywhere,
> it's just that I've found. After that, you need to be using one the of the
> approved background modes.
>
> I'd suggest usigng the power key to turn the display off and testing it
> after 20 seconds and see if you get the timer behavior you expect.
>
> *Sent:* Thursday, March 05, 2020 at 8:00 AM
> *From:* "Michael Leithner" <michael.leithner at gmail.com>
> *To:* android-development at qt-project.org
> *Subject:* [Android-development] QML Timer stops if Android Activity
> enters OnPause
> Hello there :D
> (This is my first experience with a mailing list, please let me know if I
> do something uncommon)
>
> I was wondering, if there is any detailed description on the intended
> behaviour on QML Timer / QTimer related to the Android Activity Lifecycle
> or if I encountered a bug.
>
> Background:
> We are using a Qt QML Application which sends a keep alive to our server
> every few seconds per QML Timer, which was no problem until that point,
> when I implemented the AdMob SDK.
> For iOS everything just works, but for Android it seems that this Timer
> stops sending requests if another Activity is opened above my Main Activity.
> As soon as I call Interstitial.Show (or also with RewardedAds) and the ad
> comes into foreground, my main Activity enters onPause and the timer stops
> (or better say is paused until the ad is closed).
>
> I started a thread about this behaviour in the qt forums (
> https://forum.qt.io/topic/112245/timer-stops-pauses-if-activity-is-suspended-in-android/9)
> where I was advised to enter this mailing list.
>
> Now I would like to know, what the intended behaviour of the Timer should
> be?
> Because on iOS, it keeps notifying if an Interstitial is opened,
> but as said on Android it stops.
>
>
>
> For testing, I added a Java Runnable inside my main Activity, which
> reports every few seconds --> this still gets called, after an ad is shown
> and the activity enters onPause.
>
> Then I added a QTimer within the c++ class and curiously this timer also
> stops, if the activity enters onPause, but continues onExit?
>
> Is this intentional oder did I encounter a bug? Maybe I am just
> overlooking something?
>
> Qt Creator 4.11.1 based on Qt 5.14.1 (Clang 10.0 Apple)
> building for Android with Qt 5.13.2, jdk1.8.0_241, SDK Version: 26.1.1,
> NDK Version: 19.2.5345600
>
> This is happening on x86 Emulator as well as on my good ol Blackberry Priv
> and an Samsung Galaxy S5
>
> best regards and thanks for any information
> Michael
> _______________________________________________ Android-development
> mailing list Android-development at qt-project.org
> https://lists.qt-project.org/listinfo/android-development
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/android-development/attachments/20200305/459651b1/attachment-0001.html>


More information about the Android-development mailing list