Even though it's not perfect and you can still expect background processing issues (see below) on Android 6+ devices, it's still the best there is :(. The truth is if OEMs would stop using battery saver Adding features through AOSP would make Android a much better place for users and app developers.
So even Stock Android can kill your app if you do tasks that are valuable to the user. Especially when users activate background restrictions for a specific application.
In addition, Google has drastically restricted the background processing in Android 6.0 with its doze mode https://developer.android.com/training/monitoring-device-state/doze-standby.
This attempt to unify various battery saving features across the Android ecosystem failed. Not only that the doze mode did not prevent various providers from implementing their own battery saving circuit. Doze mode made some background processing scenarios on Android impossible or, paradoxically, more battery-intensive, e.g. collecting sensor data through sensor batching.
A serious bug in snooze mode in Android 6.0 even prevented foreground services from doing their job, but luckily that was fixed in 7.0.
ANDROID P
There's a special option in Settings> Apps> Your app> Advanced> Battery> Background restrictions. If users accidentally enable this option it will break their apps. And users do enable that option!
PIE AND PRE-PIE
There is a special option under Settings> Apps> Your App> Advanced> Battery> Background Restrictions. If users accidentally enable this option, their apps will be suspended. And users activate this option!
Therefore:
- Go to Settings> Apps> Your App> Advanced> Battery> Battery Optimization
- Change view to All apps
- Choose BikerSOS
- Choose Not Optimized
ANDROID O
Make sure Settings> Apps> Your App> Advanced> Battery> Background Restrictions are not checked. If the app is not yet optimized for the Oreo API level, background processing is interrupted.
IF ALL FAILS
If everything fails, you can completely disable Doze Mode under Settings> Developer Options. (If you don't know how to enable developer options, please search Google)