What I want to achieve:
A service checks periodically if ActivityB is paused; if so, activate it, bringing it to the foreground by using CallSubDelayed.
What I've got so far:
1. When the app is active, everything works as expected.
2. When the app is in the background, for example after Home key is tapped, the CallSubDelayed will be queued, and ActivityB doesn't become active until I first bring the app to the foreground manually.
Could someone kindly point out what I did wrong, please?
TIA
A service checks periodically if ActivityB is paused; if so, activate it, bringing it to the foreground by using CallSubDelayed.
What I've got so far:
1. When the app is active, everything works as expected.
2. When the app is in the background, for example after Home key is tapped, the CallSubDelayed will be queued, and ActivityB doesn't become active until I first bring the app to the foreground manually.
Service code in svcActivateActivityB:
Sub Service_Create
Service.AutomaticForegroundMode=Service.AUTOMATIC_FOREGROUND_ALWAYS
End Sub
Sub Service_Start (StartingIntent As Intent)
StartServiceAt(Me, DateTime.Now+ 60000, True) 'start the service every 1 minute, even while the device is sleeping
If IsPaused(ActivityB) And count>0 Then
StartActivity(Main)
CallSubDelayed(ActivityB, "Activate_Me")
Else
Log("ActivityB is active")
End If
Service.StopAutomaticForeground 'Call this when the background task completes (if there is one)
count = count +1
End Sub
Could someone kindly point out what I did wrong, please?
TIA
Last edited: