Antonello Barbone
Antonello Barbone

Reputation: 103

Android kill all my app services after some time

I'm writing an android app on B4A (not an android studio) because I better know that language.

But I think the problem is related to the OS.

In my app, I have a service called "Tracker" that tracks with GPS and FusedLocationProvider the location.

Every 5 minutes the service start tracking, and when it got the location it shut down the GPS. And then it repeats this routine.

(Stopping the GPS helps to not use so much battery, usually, the GPS stays on less than 10 seconds to get the position, and then off for 5 minutes).

The problem is that the OS kills all the services (including starter).

I leave the phone on the table for hours, sometimes the OS doesn't kill the services for hours, other times it kills it after 30minutes (it is random).

the Tracker service it's a ForegroundService And it's scheduled to restart itself every 10minutes (but as I said, after some hours it doesn't do it anymore).

What's the problem?? I'm getting crazy

I tried to add this permissions:

AddPermission(android.permission.FOREGROUND_SERVICE)
AddPermission(android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)

I tried to declare it as STICKY_SERVICE also

Upvotes: 0

Views: 506

Answers (0)

Related Questions