• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Background Location Limitations

When Froyo was released, I wrote a fleet tracking app for my employer thats sole purpose was to check the location of each vehicle every 60 seconds. When the vehicle was moving, it updated these new locations in a bundle every 10 minutes onto privately owned servers. I did not make the app available on Google Play Store.

I took a break from Android developement for a few years while I went back to college. The app is outdated enough that it will no longer install on current phones. Looking through what I have to do to update it, it appears that doing so will be a waste of time. From developers.android.com:

In an effort to reduce power consumption, Android 8.0 (API level 26) limits how frequently an app can retrieve the user's current location while the app is running in the background. Under these conditions, apps can receive location updates only a few times each hour.​

The qualifying statement appears to be, "In an effort to reduce power consumption..." One could assume that if the phone is mounted in the vehicle and plugged in, the above statement, "apps can receive location updates only a few times each hour" would not apply. However, before I spend a significant amount of time rewriting the code, I want to pose the question:

Is the limitation of background updates firmly set at a few times each hour with no exceptions? Or is there a workaround, such as when the phone is plugged in and charging?
 
I'm not a developer, but based on the apps that I use you should be able to get around that restriction by having the app run in the foreground, by registering a persistent notification.
 
Technically that doesn't answer the question of a way to make background location work as described in my original post.

In this case, your solution won't work because it requires that the driver take action and always keep the activity on top. With the current ELD requirements and other apps the driver needs to use, such as for communication with the company, keeping the location activity on top doesn't meet the company's needs. As much as we like to think that all employees are unconditionally cooperative, the truth is, many live for any opportunity to sabotage what the company is doing. Relying on the driver to babysit the app isn't an option.

I have to confess, I'm a little surprised at this limitation. If a user installs a third party app and suddenly has trouble with the battery draining quickly. They have options:
  • Uninstall the app. In the past when I've had this trouble, I've uninstalled the offending app, Then if/when I've needed it, I've reinstalled it long enough to use it, then immediately uninstalled it again (hint: 3rd-party app - it's there only because you allow it). Thanks to Samsungs password feature, it keeps the passwords of uninstalled apps so I don't have any trouble quickly logging into any reinstalled apps.
  • They can refuse to allow or revoke background location permissions at any time.
  • They can find another app that provides the functionality they need without the heavy battery drain.
  • They can plug the phone in.
The bottom line is that with this restriction regardless of the logic or reasoning behind it, the phones are of no value to us.

Regarding personal use: I use weather apps' radar feature to track severe storms when on the road. On a 500+ mile drive, when I know I may run into severe weather, I periodically pull up the radar to get an estimate of about where I'm going to intercept the storm. In the old days, the app would regularly (every couple of minutes or so) update my location while keeping me in the middle of the screen. And as I approached the storm, I could zoom in and know within a mile or so when I was going to hit the 50+ mph squal line or storm front. This would allow me to pull off somewhere close to but short of the front. Then I could immediately leave as soon as the worst part passed.

This feature no longer works unless I force-stop the app, then restart it. Radar apps that used to track me now don't. They show me as where I was when I took my last 10-hour break. I can be down the road 400 miles, and they still show me several states back at my original starting point. To find the radar at my location while driving down the road, I now have to take one hand off the wheel and move the map to my best guess as to where I am (radar events often cover the highways, cities, and state borders so you can't at-a-glance see where you are on the map). Then I have to hope that I guessed correctly.

Background location use is a feature that I've relied heavily on both for business use for my employer, for safety during severe weather events, and so my wife can track where I am and where I've been (breadcrumbs that I happily wrote into the app for her - happy wife, happy marriage) when I'm on the road. Losing this feature has us looking around for other options.
 
In this case, your solution won't work because it requires that the driver take action and always keep the activity on top.
That isn't the case. It is a permission granted to the app that gives it a persistent notification, think an alert that you cannot swipe away. This allows the app to operate with the freedoms of an app running in the foreground without requiring action by the user.

I don't remember why, but the app for my Wyze cameras has to operate this way in order to give me alerts when some type of motion is detected.
 
This still doesn't anwer the question posed. Foreground doesn't work. We need apps that do what we need in the background without our having to sit down beforehand and start all the apps we might use during the day so I can access the information that I want when I want it.

My wife spent a week in Indiana earlier this summer. Her favorite weather app, which used to follow her flawlessly, is still giving her weather notifications from Indiana. Maybe you can explain to me why we would want severe weather notifications from Indiana loudly interrupting what we're doing when we live in Minnesota.

Our favorite apps, which rely heavily on location, are no longer working. Android's current implementation of location is broken. I have better things to do with my time than to coddle the android apps I use to make sure they provide the information I need when I need it.

The obvious answer to my question is, "No, there's no work around." We're looking at iPhones. Our granddaughter has been nagging us for some time to make the switch. My Goldwing only works with Apple CarPlay. We have no reason to stay with Android using apps that have lost a significant part of their functionality.
 
The obvious answer to my question is, "No, there's no work around." We're looking at iPhones. Our granddaughter has been nagging us for some time to make the switch. My Goldwing only works with Apple CarPlay. We have no reason to stay with Android using apps that have lost a significant part of their functionality.


To be fair, one can't really blame Android for Honda's decision to only support Apple's proprietary things...it's called vendor lock-in... and $$$ in kickback between Apple and Honda.

I've not a dev so can't help you course, but there still apps that can run in background and have real-time updates, e.g. COVID track and trace apps. So there probably is a way to do it.
 
Last edited:
I talked it over with the Mrs. Regardless of the reasoning, the apps we rely on are no longer working properly, and I'm not seeing any indication that the cause of their failures will be resolved anytime soon. So I ordered two iPhone 13 Pro Max phones to replace our Samsung Galaxy Note 10+ phones. T-Mobile says they're on backorder. Estimated delivery is the first week in November.

I consider the discussion closed. I don't know if there's a way to officially mark it as such. :)

Best wishes,

Glen
 
If I'm not mistaken, I believe iOS imposes even stricter background location tracking restrictions.

Android gives several ways to get around the limitations without destroying the device's battery life. I use several apps which need to regularly update my location and they're still able to work just fine - provided that their developers have adjusted them using one of the methods described.

In any case, I'm sorry that we weren't able to help you adequately here. I hope you'll enjoy your new iPhones.
 
codesplice,

You may be correct. I've never used an iPhone, so I'm going into this blind. Please understand, the Mrs. and I haven't been enticed away, "The grass is always greener..." The fact that Apple CarPlay works on my Goldwing and Android Auto doesn't wasn't a consideration in the decision.

I've gotten by the last 1½ years riding my Goldwing by starting whatever I want to listen to on my phone before I head out, and piping it directly to my helmet through bluetooth. Goldwing disables most access to its media system once the bike is rolling, so I'm likely stuck with whatever I'm listening to either way.

We love our granddaughter, but she's young and inexperienced in life. When her iPhone was stolen a year+ ago, we loaned her a Galaxy Note 5. She wasn't happy with it. Always polite and respectful toward us, she didn't say why. When she was heading off to college, we told her she could pick out her phone of choice and have it on our plan as long as certain conditions were met (she stayed in college with respectable grades, we could afford to make the payments, etc.). She chose an iPhone 11 Pro Max. It started acting up recently, throwing her into a panic. I asked her if she wanted to borrow one of our Android phones. She made it clear that she wanted her iPhone. It started working after a hard reboot and a new simm card. She was delighted to have her iPhone back.

We're leaving because Android has become a source of irritation, even a liability. I need a phone, while driving in the middle of the night in severe weather and low visibility, that allows me to click on the desktop radar link, with the phone immediately pulling up the radar with my current location in the middle of the screen, and then follows me down the highway consistently updating the radar and my location with no more action required on my part. The current implementation of location doesn't do that. I can go through the whole 535 mile trip with location never updating. The app that I wrote when Froyo was out only updates every couple of days. It used to reload the location every 60 seconds.

The Mrs. is switching to iPhone because her phone is still showing her in Indiana even though she's home in Minnesota, and she's receiving severe weather alerts from Indiana. For whatever reason, Android decided that receiving severe weather alerts is an imperative , so disabling these notifications isn't allowed.

[Edit] I can't stress enough how irritated she is that Android took away her ability to pull up the history of my locations since I wrote the app (a few years ago) and see everywhere I've been and how long I've been there.

The bottom line; Android believes that the average user isn't capable of making simple decisions as to what's best for them, so Android is making the decisions for them. We'd stay if we had control over our phones, including the option of running location as a background or foreground service, and the ability to shut off all notifications, including system notifications, so we don't have that infernal phone demanding our attention anytime day or night.

Respectfully,

Glen
 
Last edited:
Something to consider:

The issue is that there are too many background services (apps that may or may not have an active activity) requesting location updates in a largely (or wholly) uncoordinated manner.

Possible solution:
  1. Disallow all apps, both system and 3rd party apps, from directly initiating location updates.
  2. In settings, set up a user configurable location update where the user would determine based on varying conditions (wifi or cell tower, charging or on battery, walking or jogging or driving...) how often the location would be updated.
  3. Require that all background services use the location updates that are provided by the periodic update intervals set by the user.
  4. Allow apps to request updates at certain intervals on install. The user can then approve or disapprove the request, and change them at any time. I.e., if the user sets a default location update on battery to hourly, and a walking app they install requests 5 minute updates, the user can approve or disapprove the request, or set it to some other update interval.
Settings for Location might look something like this (my apologies for not setting up actual radio buttons here):

Location Update Intervals:
On Battery:
  • No Updates
  • 5 minutes
  • Hourly (default)
  • Daily
  • Other (in minutes)
While Charging:
  • No Updates
  • 5 minutes (default)
  • Hourly
  • Daily
  • Other (in minutes, or -1 for continuous updates)
etc.
 
Or, rather than rearchitecting the entire OS to support your app, you could update your app to support the location service methods permitted by the OS.

If your app runs with a foreground service (even while the app is in the background, courtesy of a persistent notification) then you can poll for location updates at any interval you desire.
 
codesplice, as I've said, the new system doesn't work. Two weather apps I heavily use written by professional developers no longer work. One leaves me at at my origination during my entire 500 mile drive. Thursday morning I found myself trying to get it to update while approaching what appeared to be heavy rain in the Des Moines area. I hit the location update button several times to no avail, force stopped and restarted it several times, findally did a hard reboot on my phone. It never updated my location.

The other app that is radar only correctly loaded my position on startup (meaning the phone was receiving gps from the satellites). But that's all it did. It used to follow me for the entire 535 mile drive. Now it will only update when I press the gps icon. I'm forced to press the gps icon ever time I want an update.

Friday on my return to Minnesota, one app previously mentioned showed me in Kansas, the app I use as my backup log in case the ELD goes down showed me in St. Paul (not even close to where I was), the tracking app I wrote was the closest. It said I was 10 miles away. None of the apps were accessing my current location, even when I was finally able to manully update the log book app by pressing on the location button (which is illegal while driving).

Thanks for responding, but I have better things to do with my time than to try to write apps for a system that professionals can't get to work.
 
Back
Top Bottom