codepath / android_guides

Extensive Open-Source Guides for Android Developers
guides.codepath.com
MIT License
28.29k stars 6.36k forks source link

Run JobService forever until user decide to kill it. #376

Open tvaknin opened 4 years ago

tvaknin commented 4 years ago

Hi, I used your guide to run a Background Service via JobScheduler and send that information with broadcast receiver to the main activity. My app gathering barometer sensor data in the background. The problem is that Android Destroy the JobService after a few minutes. Is there any option to run JobService forever?

Thanks

tvaknin commented 4 years ago

Found solution - use foreground service:

https://stackoverflow.com/questions/47531742/startforeground-fail-after-upgrade-to-android-8-1/51281297#51281297