I am trying to get geolocation in my Xamarin Android app using LocationManager.
When i used GPSProvider as the location provider, OnLocationChanged didnt execute. Then i tried NetworkProvider and OnLocationChanged did executed and i could find the geo location.
What is the difference between GPSProvider and NetworkProvider and which will be more reliable?
GPS might not have given you any location, because when you are indoors, the signal can go from very bad to unavailable. Use FusedLocation as it manages the providers and will use the one that gives the best location at any given time. If you are indoors, it will use the Networkprovider. If you are outdoors it will use the GPSProvider
If you don't wanna use FusedLocation (needs google play configuration) you can try GetBestProvider then the device will select the best provider for a criteria
Documentation and code sample here
Related
Is there any way to get location of the iPhone without demanding location services from the user? It should not be really accurate.
edit: I have no problem with implementation of location services. I try to find an alternative way
No this is not possible.
Apple has made location service abstract so you can't really see which technic is used. Thus if the user turns off the location service you can't get the location any other way.
There is however the option to check the user IP and get a very rough location.
TL;DR:
My objective: Try all forms of getting a location and then choose the most accurate one, (try get a location for a minute then time out).
I'm a little confused about where it gets the location from, is it GPS? Cellular? or a mix of both depending on toolkit?
While getting location on Android I used both and then choose which provider based on accuracy. I do not see anything similar for iOS.
I'm using CLLocationManager which is showing good accuracy but I'm not sure where the location is from.
On iOS, location manager is built more intelligently. Relying on your configuration, it either uses GPS or WiFi/cell radios, as described in the CLLocationManager documentation:
For the services you use, configure any properties associated with
that service accurately. Core Location manages power aggressively by
turning off hardware when it is not needed. For example, setting the
desired accuracy for location events to one kilometer gives the
location manager the flexibility to turn off GPS hardware and rely
solely on the WiFi or cell radios, which can lead to significant power
savings.
For more information, read
CLLocationManager documentation.
EDIT
And, If you want the most accurate location, you should put kCLLocationAccuracyBestForNavigation for location manager's desiredAccuracy property.
I would like my iOS app to get notified in background whenever user stops (or slows down below some velocity threshold) at a place while maintaining maximum battery life.
The catch is that I don't really care for accuracy when the user is moving but I need as accurate measurement as possible when user stops or walks around the same spot.
There are many Core Location tools available:
Standard Location Service
Significant Change Location Service
Geofencing and Ranging Service
Integration with Core Motion and M7 Motion Coprocessor
Which one of them should I use? Is there a best practice for what I am attempting to do? Has anybody experience with this sort of stuff? I found this app which does exactly what I want to incorporate in my app but I'm not permitted to use their API.
I've read the documentation but my case doesn't really fit any of the categories they discuss.
Thanks in advance.
Pete.
In iOS8 there is a new technology that fits what it sounds like you are asking for. CLVisit objects are sent to your app in the background when the user arrives or departs after stopping at a location. Power consumption is very low with this feature. You enable it by calling startMonitoringVisits on a CLLocationManager object.
I need to allow manual positioning over a map if user location remains under a given accuracy a certain amount of time.
I need a way to test this circumstance. It's not like disable location services. Just want to have bad GPS signal (for example: horizontalAccuracy about 500 m. or so). "Unfortunately", in the place I work (my own house) I have a strong GPS signal so I can't test and fine tune the app behavior.
I wonder if there's a way to do this. Something like the network link conditioner in the developer menu on iPhone settings.
As far as I know, there's no way to do it short of writing a test class to inject location data. (I.e., there's nothing in the location simulation functionality provided by the simulator and/or debugger that will allow you to set accuracy.)
This answer to a similar question has an example of the manual-test-class-hackery way.
I want to use CLLocationManager to get the current user location using GPS antenna, not the cellular network. How can I ensure that?
Your choices is either the standard location service (e.g. startUpdatingLocation, for which you can specify the desiredAccuracy), or the low-power significant change service (e.g., startMonitoringSignificantLocationChanges). But you generally don't specify location services based upon hardware, but rather on the basis of your app's functional needs. Use the standard service if you need an accurate location, and try using the significant change service if you don't need the same level of precision.
See the Location Awareness Guide for more information.