Android Question Check if the app is active

Alex_197

Well-Known Member
Licensed User
Longtime User
Hi all.

I'm using this code created by Erel to check if my app is active or not.

B4X:
Sub IsAnyActivityVisible As Boolean
   Dim jo As JavaObject
   Return jo.InitializeStatic("anywheresoftware.b4a.BA").RunMethod("isAnyActivityVisible", Null)
End Sub

I also have a timer ticking every minute is Service that checks if the app is not active and if not it counts to 30 and redirects the user back to the login screen. It works like on the web site.

What I've noticed - if the user starts another app and returns to the app 30 minutes later he needs to login back to the app. But if the user just left the phone on the table and the screen timed out (gets dark) and when the user returns back to the app even 1 hour later he can see the same screen he was 1 hour ago and doesn't need to login back.

So my question is if the screen timed out does it mean that the app is inactive or not?

Thanks.
 

DonManfred

Expert
Licensed User
Longtime User
o my question is if the screen timed out does it mean that the app is inactive or not?
When the screen become dark the app is send to background.
Due to this there is no visible activity.

isAnyActivityVisible- i guess - will return false
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…