Closed shamun closed 7 years ago
Is there any way, to go in the foreground when in my backend i have some status received from my own networks? (so that i can implement ringing or UI on screen lock or other state )
I think you are asking if there is a way for you app to jump to the foreground.
Normally if there is an event that the user should interact with, I would have the background service create a notification (https://developer.android.com/guide/topics/ui/notifiers/notifications.html). The user could click on the notification opening the app.
Not exactly i am looking for notification.
But when my background service is running, i am doing a crawling to my server where it says "mom calling". On that moment even the mobile is in lock mode or my app is not running on focus, i wanted as following GUI (ringing). Note: currently, it works when my app is not closed or active on the screen (at-least a ringing works, without GUI auto showing on front screen)
If you program that background logic into the background service, it should continue running even if another app takes over the frontend. Note that that logic needs to be in Java (not JavaScript) and running in the MyService.java doWork (if you are amending the bgs-sample code).
Occasionally the background code maybe killed - but this seems to be a restriction enforced by Android when the device simply doesn't have enough resources.
Using the sample https://github.com/Red-Folder/bgs-core/wiki/Using-the-MyService-Sample i can see it works when i come back to my app by having the real focus only on my app.
But my app need to run absolutely in the backend (like you start the app once and you put it by hitting back or close).
Is this normal? (how would you really let the app run forever with back or close) When i hit back or close my app focus and using some other app, then it never playing my ring crawl. it is only crawling or ringing when my app is absolutely on main focus.