Android Question [B4APages] About background tasks and services

vfafou

Well-Known Member
Licensed User
Longtime User
Hello!

I would like to ask the following:
As I understand, I could have the Starter service for background tasks like push messages functionality with web sockets, send/receive messages via the websocket push framework and background GPS management to send location data to server even if the app is in "background". I also need to "wake" the app from "background" when receiving specific messages.
Things I need to clarify:

1. Do I really need a background service in order to keep the app alive when in background?

2. If yes, should I remove the following line from Starter service, in order to prevent the process being killed from Android?
B4X:
Service.StopAutomaticForeground

And do I need StartServiceAt?

3. Could I use notifications like any other app with background service running? If the service is not needed then how notifications are implemented?

4. How do I "wake" the app from "background"? By now I did the following inside the background service running as foreground service:
B4X:
If msg.type = "ET" then
    If IsPaused(Main) Then
        StartActivity(Main)
    End If
End If
With B4XPages, what is the equivalent?

Thank you in advance!
 

OliverA

Expert
Licensed User
Longtime User
Everything is continuing to run exactly as before. Timers run. Sleep calls will be resumed and so on.
Exactly like in B4J and B4i.
(emphasis mine) Here I got all excited, but B4i's behavior is the same as before: once in the background, timers stop/pause until brought back into the foreground. It may not be an immediate cut off, but timers will eventually stop within a few seconds of the B4i app going into the background.
 
Upvote 0
Top