Switch GPS provider

Hello from Italy! (Sorry fo my bad English :grin:)

I've created an app for loading geotagged photo on my server, all is running fine but I've problem with GPS fix

If I select "network" as provider the app fix quickly but with the default "gps" provider it takes a lot of time to fix.

My questions: is goog to set "network" as default gps provider? (I will find a provider named "network" on every android device? On my device when I call availableProviders the result is: "gps" - "passive" - "gps" - "network". For sure I can check the presence of network provider before switching to it)

It will be better use "network" for fixing and then switch to "gps" to obtain better accuracy? If yes, is it possible to use two location sensors setting one on "gps" and the other on "network" and use the position with better accuracy?

Thanks a lot!

No. The accuracy of gps data is automatically determined by your GPS hardware and the number of satellites your gps can receive at any instance although you can force gps to run.

The time it takes to get a satellite fix is determined by your gps hardware, whether you have an unobstructed view of the satellites, weather conditions etc. The initial fix may take 20 to 60 seconds, subsequent fixes about every 20 seconds (or perhaps a bit less depending on your hardware).

This is probably because the LocationSensor is using WIFI to provide a position. The most accurate geocoordinates are provided by the gps + on some devices. My recommendation is not to set a Provider but let the software 'decide'.

Have you read Using the Location Sensor. The document explains it all. :slight_smile:

I don't know if you can run two instances of the LocationSensor simultaneously. Why don't you try and let us know what you find. I expect the gps will generally indicate better accuracy (that is what the literature says :wink: )

Thanks a lot!! I will going on testing..

Ok, is possible to use 2 locationsensors at same time with different providers:

So I can use the network provider (very quick fix) and then switch to default gps provider (better accuracy) when it has a fix.

Now my problem is: if I turn off the sensors

And then I ask for latlng:

The sensors send me the last fixed psotion but in my app I really need to have the opportunity to disable the location.sensors in a way that If I call the latlng they send to me the standard nofix 0,0 value.

A sort of in app reset for the locationsensors!

Thanks!

I do not think you can zero out the last known coordinate. See the LocationSensor documentation.
The most recently available latitude or longitude value in degrees will be reported to 5 decimal places. If no value is available, 0 will be returned. Your app provides a 'most recently available longitude or latitude has been set' so you do not get 0. There is no Method to set/reset the LocationSensor.Latitude or Longitude to 0 .

Why? To report coordinates of 0,0 do not use NETWORK_gps.Latitude/Longitude after you disabled a sensor. Simulate coordinates of 0,0 by setting a variable myLatitude or my Longitude within the LocationSensor1.LocationChanged event. Use the myLatitude/myLongitude varibles as your app's reported coordinate( instead of the last reported coordinate indicated by the LocationSensor). That is, set each of myLatitude/myLongitude to 0 after your LocationSensor1 or 2.enabled is set to false. Use the simulated coordinates for your strange requirements; not the LocationSensor.Latitude / Longitude Blocks.

Experiment

My app works this way: when I take a photo I ask sensor for position and upload pics and latlng to my server.

The GPS provider when fixed offer the best accuracy but it cannot fix indoor and in some situations can take a lot of time to fix. So I decided to use two sensor at sdame time (gps and network) When I ask for the position my function choose the provider (gps or network) with best accuracy value. If I am outdoor the GPS fix and offer the most accurate position, indoor where the gps provider can't fix, the Network provider provide accetable position.

BUT when I go indoor and the GPS provider loose fix it continue to provide the The most recently available latitude or longitude and accuracy value and my function continue to choose this old position because has better accuracy compared to the "real" network position.

So I need to stop a non fixed provider to send to me the last availvabe position/accuracy because even If i turn off the sensor with the gps provider when I turn it on again it re-start to provide the most recently available latlng but this position could be miles away from the real position until the gps provider fix again, and if I am indoor it can be a serius issue.

So my requiremets are not so strange.. :grin:

Post #5 describes a solution. :slight_smile: Did you try it?