Run background services on battery saver mode Android

mauriballes :

I have a service for sending http request that runs on background and works fine on "normal mode". The problem is when I put my phone on "battery saver mode", the service not working. But, apps like Whatsapp still working. Do you have any idea what's going on?

Sagar :

Mobile applications like Whatsapp must be requesting permission to exempt them from Doze/battery saving and App standby mode.

It is possible to configure this manually by configuring the Whitelist in Settings > Battery > Battery Optimization.

Alternatively from API 23, you can use permissions model to request users to whitelist them (refer this). From API You can also check whether your app is currently on White list by calling isIgnoringBatteryOptimizations()

However you need to satisfy certain criteria for being able to whitelist yourself. Otherwise you face issues while maintaining app on Google Play Store.

But mostly messenger apps like Whatsapp are triggered through high-priority push notifications so they are more likely to be active despite not running background process.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=438651&siteId=1