Android Tutorial Background Services in Android 8+ - Observations !

Jmu5667

Well-Known Member
Licensed User
Hello

I would like to share some observations with you all, is is based on https://www.b4x.com/android/forum/threads/background-location-tracking.99873/#post-628468

A problem that we all have in 8+ and backgound services is trying to keep them alive. I have been testing a bg service on a Huawei Y6 running android 8. In the above example that Erel did he update the notification bar every 10 seconds and the app will never be killed.

In my service I updated the notification every minute, but the device stopped giving me time, it became rather intermittent.

when I changed the update to every 5 seconds it would appear to work correctly. I am currently doing more tests, the phone will vibrate every minute to let me know it is still running.

Just thought I would share this. On this device you need to explicitly all the app to run in the background in the settings. That being said it would appear to ignore this under certain circumstances.

Regards

John.
 

Cebuvi

Active Member
Licensed User
Hello,

I’m trying to maintain a background service and I’ve read your work.

I would appreciate any information you can give me on how to maintain it, how long it is possible to do so and whether it has a lot of battery consumption.

Thanks.

César
 

Erel

Administrator
Staff member
Licensed User
I have been testing a bg service on a Huawei Y6 running android 8. In the above example that Erel did he update the notification bar every 10 seconds and the app will never be killed.
You are confusing different things.

Updating the notification has nothing to do with keeping the process running. It is just the way that specific app updates the location information.

The process is kept running because of:
- The foreground service.
- The partial wake lock.
- And the StartServiceAt call which helps in the case the process was killed.
 
Top