I am attempting to simulate a very simple function - like that of the default Android "Clock / Timer" function. If you open the "Clock", select "Timer" and set an amount of time - you can return to the HOME screen (or begin working in any other application) and, when the time on the timer expires, an activity screen will appear (and interrupt you, regardless of what application you are currently using in the foreground) announcing the expiration of the timer.
My B4A app launches a very simple screen (allowing the user to choose the number of minutes to delay) and then sets a corresponding service to launch on a delay using "StartServiceAt". When the service launches, I use "CallSubDelayed" to launch the activity screen to notify the user that the timer has expired.
The application works fine - as long as my program is still "active" at the time the service launches. If my application is in the "background" at that point (say, after pressing the HOME key after setting the alarm) - B4A displays a message:
After reading the documentation, I assume that this is what is to be expected, based on:
My question is... How do I get B4A to "force" my application screen to the foreground when the service starts?
My B4A app launches a very simple screen (allowing the user to choose the number of minutes to delay) and then sets a corresponding service to launch on a delay using "StartServiceAt". When the service launches, I use "CallSubDelayed" to launch the activity screen to notify the user that the timer has expired.
The application works fine - as long as my program is still "active" at the time the service launches. If my application is in the "background" at that point (say, after pressing the HOME key after setting the alarm) - B4A displays a message:
B4X:
sending message to waiting queue (CallSubDelayed - DisplayAlarmScreen)
After reading the documentation, I assume that this is what is to be expected, based on:
B4X:
http://www.b4x.com/android/forum/threads/using-callsubdelayed-to-interact-between-activities-and-services.18691/
- If the target module is an activity:
- If the application is in the background (can happen when a service calls an activity) then the message will be stored in a special message queue. In this case the sub will be called when the target activity becomes visible. The sub will be called before Activity_Resume.
My question is... How do I get B4A to "force" my application screen to the foreground when the service starts?