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.
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.
when I turned on gps with code,gps icon blinking in notification bar.but when I go to location setting, I see use gps sattelite option dont checked and I can not show location on phone maps.
when I go to location setting and checked use gps sattelite option, I can see my location on maps, but gps icon blinking yet on notification bar.
I think gps is not enabled actually, is right?
Correct. GPS is most likely not enabled. Starting a long time ago, you cannot directly toggle GPS on/off.
You can send an intent that brings users to the settings screen, where they can change it themselves. See this question for more details on that.
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.
Is it possible to determine programatically whether any background applications/services are using the sattelite GPS functionality?
I realise from searching SO that it isn't possible to disable it in code, but that I have to use a button shortcut which does:
Intent myIntent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
startActivity(myIntent);
and click the relevant settings button.
I've written a maps application but have no access to a real phone at present and notice that the little satellite icon in the emulator's status bar doesn't reflect the state of the system setting. I'd like to try and conserve battery charge and am wondering whether the GPS stays on, draining the battery, if nothing requires its functionality.
I realise that disabling satellite GPS at system level may impact other apps, hence my question.
You are confused about things.
There are disabled/enabled and radio ON/OFF states.
As you say only the user can disable/enable use of GPS functionality via the setting you invoke. At this time the chip is not activated, only enabled. Battery is not drained.
When an application starts using the GPS, the radio will go ON so the chip will be activated, battery drained.
So once your application no longer uses the GPS, just stop using it, make it radio off (unsubscribe any receivers etc..) leave it enabled, and the user might disable if he really wants.