Android Question Background Services on Android 5 and above

carloz

Member
Licensed User
Longtime User
hello Forum,

I have a app with multiple background services to handle location tracking and alarms. So far the app was working perfectly well and all services were starting properly when scheduled .

On 5.1 and above none of the services are starting as scheduled, also tried to make the services sticky, but as soon as the app is swiped from the recent list or ExitApplication is used, the services are stopped and do not restart...
I see other apps like facebook,whatsapp,truecaller and many others having background services and they do not encounter the same issues that i am facing..

Can someone point me in the right direction? what am i missing here?

regards
carloz
 

carloz

Member
Licensed User
Longtime User
hello,

Has anyone faced this issue? i tried to restart the service from the starter service "Service_TaskRemoved" .. but no luck

regards
carloz
 
Upvote 0

carloz

Member
Licensed User
Longtime User
hello erel :) good morning!!

I did remove the exitapplication .. also tried to start the service as a foreground
B4X:
sNotif.Initialize
    sNotif.Icon = "icon"
    sNotif.SetInfo("xxxx","yyyy",Main)
    sNotif.Sound = False
    sNotif.Light = False
    sNotif.Vibrate = False
    sNotif.Notify(1)
    Service.StartForeground(1,sNotif)

but same results :( as soon as the user swipes from the recent task list .. the service is stopped and the foreground icon is cleared too ... am i missing something in the manifest? im on api 23

thnx for replying
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is not the "correct" behavior. I don't think that you can do anything about it. Worth looking for power related settings.

It seems like the manufacturer implemented the swipe feature as it it is a "force stop". This means that the process is always killed and cannot be restarted unless the user explicitly starts the app.
 
Upvote 0

carloz

Member
Licensed User
Longtime User
i agree..thats what has me stumped...funnily when i swipe the facebook app from the recent list ..its service is not killed...how could they be managing that?
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
It is also possible that facebook app is treated specially.

Huawei calls it "protected apps". If you have one, set your app to "protected". FB & WhatsApp get these status automatically (due to definition). 3 months ago Huawei brought an extra system update because they had WhatsApp not in their whitelist (which caused a lot of problems because users wondered why on their "new highend phone" WhatsApp "did not work/no FCM messages arrived, etc.". Even my Goggle calendar widget did not update due to this.

Took me a lot of time testing and getting mad because my first FCM app did not receive any messages when the screen was off :mad:
 
Upvote 0
Top