I am writing a program in Android that uses GPS. It will prompt the user to turn on location services if it is not on (which I guess is equivalent to turning on gps ?). My question is: does the gps immediately start consuming extra battery power as soon as location services is turned on or it uses batter power whenever the location services is queried/used for a new location ?
The GPS starts working only when the location manager requests an update from it. Turning on the GPS in the device only allows programs to request locations if they want, but it doesn't mean the GPS is kicking in.
You can test it yourself: The GPS icon in the notification bar tells the GPS status. You can turn on the GPS, but the icon won't appear. Why? No application requests updates now. As soon as an application requests an update, the icon starts blinking (The GPS is initializing itself) and when it stops, it means the GPS is initialized and is currently receiveng updates.
The GPS consumes battery only when this icon appears.
My company wrote a blog post on this subject a while back. Check to see if its useful.
http://www.littleeye.co/blog/2013/03/29/understanding-gps-resource-usage/
But we missed talking about what happens when no app is actually requesting for a location update. And yes, as mentioned unless apps actually ask for a location update, they will not cause power drain. But note that even a single request for a location update (depending on coarse or fine grained request) can have unintended effects, as the device has to go thro various states before it can get back to its steady state.
Turning on location services is just permission given by user to applications for using location services. As long as any application not asks for location, power consumption is the same as with location sesrvices turnded on.
On the other hand - there is many applications trying to get location. Facebook, Camera, Android, many of ads libs, so yes - user can get battery life issues when GPS is unlocked.
Related
On Android, we can retrieve CellLocation using this API
This API requires location(Coarse or Fine) permission to be granted.
We observed that API returns valid CellLocation even if global location-setting is OFF. Ideally, it should not give cell-location when location-setting is OFF.
Is the current API behavior intentional? Is it a bug in Android? Is it OK to access CellularLocation even if location setting is OFF?
There are two separate systems here:
App permissions
User toggles
If an app received the Location permission, it's allowed to use the API to get location whenever and however is wants (you should obviously take battery and data usage in consideration, but that's up to you).
If a certain settings toggle is switched on or off by the user, it's up to the API to turn off certain features from apps, it's not the app's responsibility to check system settings whenever it wants to use an API.
In your case the location setting can be toggled by the user to prevent usage of the GPS component to prevent accurate location tracking and to save battery.
This does not apply to cell-tower location as it's definitely not accurate and the data already exists on the phone so no battery power is needed either.
Android may in the future turn off cell-tower location when this setting is off, but until then you're allowed to use whatever the API gives you.
I'm developing an IOS / Android gps based application that needs to update location always (or after significant location change). Similar to Life360 family locator app. This app doesn't need to start at all and yet when you open the app it has all your location data captured for a week. If I'm checking on my kids location and they don't have their phone actively running the app, I still get the real-time location and their gps history.
How is this accomplished? It seems that the app is logging gps data, not only when in foreground and background but when not running at all. Is there a special run-mode these apps use?
thanks all!
Mike
I can only speak for iOS.
On iOS you can register for significant location changes, and your app will get notified in the background when a location change event occurs (and even get launched in the background if it had been terminated). You can then request background time and transmit your updated location information to your server.
How often does the GPS check for location changes without being specifically asked with requestLocationUpdates? Does that change when the screen is off?
My app just sets up a proximity alert, without any background service running, and it plays a sound when entering the proximity. I'm trying to find out the limitations to this approach, if there are any.
As long as the GPS chip is enabled it sends 1 location per second to the API.
Is it possible to launch an app depending on the user location. I want the app to start only when I enter certain location say my office. I m aware about services running in background but I dont want my app to continuously check for location and deplete the battery.
Is it possible to register for some sort of geo-fencing broadcast ?
You can Create and Monitor Geofences with a standard Google API.
However, if you want to know if you've arrived at your office, I think a better and more battery-friendly way would be to see if you're connected to the office Wifi network.
i am currently developing an app that requires location from the start. I have a method that checks if location updates are up, but even when GPS is turned up I cant ensure a Location Update when the app starts. How can I ensure a fresh location update when my app starts?
i am currently developing an app that requires location from the start.
That is a design flaw in your app. Please redesign your app to take into account that:
the user may have GPS disabled, or
the user may not have used GPS recently, so it will take some time to acquire a fix, or
the user may not be in a location where GPS signals are available (e.g., inside a large building)
How can I ensure a fresh location update when my app starts?
You can't.