Android Question Multiple Activitys with Service

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

Just wondering is there a easy way to detect if any activity in the app is open using a service?

From my service I am using:

B4X:
dim SomethingOpen as string = "no"
If isPaused(Activity1) then SomethingOpen = "yes"
If isPaused(Activity2) then SomethingOpen = "yes"
If isPaused(Activity3) then SomethingOpen = "yes"
If isPaused(Activity4) then SomethingOpen = "yes"

If SomethingOpen = "yes" then
' run this code as one of the Activity's is open
end if

However is there better code to use to detect if any activity is open using a service ?

I guess I could use the above code but the problem I have is if I add more activity's at a later date, I am scared that I will forget to add it to this code so if there was another way without worrying about modifying this code each time.
 

mc73

Well-Known Member
Licensed User
Longtime User
I think isPaused is a little 'problematic' since it will return true even when an activity is not started.
 
Upvote 0
Top