4

I have a GPS tracking Android app that receives continuous push messages when someone requires user's position.

Everytime that I receive a push, I start the location service that send positions during X time while he is receiving push messages.

The problem started with android Doze system, that block http requests. I could receive messages but I never could send my current position (I received timeouts of http connections and error in pings to Google). But i could solve it with ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS request and adding the app into battery whitelist programatically.

Now, the app works fine in all devices except on Samsung devices over S6, that have "Smart manager" system. I tried to add manually the app into Samsung's battery whitelist (Setttings -> Device Maintenance -> Battery -> Unmonitored apps) but the problem persist.

If I keep the device with screen off and no charging, in a few time, it stops sending positions, but he still recieving push messages.

Can anyone help me with a magical solution? I saw a alleged "packages list" with a lot of apps that Samsung includes automatically into whitelist (Facebook, Whatsapp, Life360, for example) but I couldn't find what I need to do to add my app into this list automatically.

Xose
  • 544
  • 1
  • 4
  • 12

1 Answers1

0

Based on the link provided by @ManmeetP, it looks like your only option is to use Samsung's "Knox" SDK: ApplicationPolicy.addPackageToBatteryOptimizationWhiteList()

https://seap.samsung.com/api-references/android-standard/reference/android/app/enterprise/ApplicationPolicy.html

This would mean bundling that SDK into your app for all your users =(

tir38
  • 9,810
  • 10
  • 64
  • 107