Location Service does not restart

430
2
06-15-2013 05:56 PM
ThomasBinu
New Contributor III
I have a very weird problem with the Esri location services class. I am testing on two galaxy s3s. I have a button in my application to toggle the location service on/off. Initially when I load the map, the application acquires my current location without any problem. But sometimes, when I turn OFF the location service and then  turn it back ON , the current location icon appears but remains 'gray' (the onLocationChanged method in the locationChangedListener never gets called, hence the locationservice does not start properly). This issue occurs randomly both my phones from time to time. Has any faced this problem? Can any one from Esri comment on the issue?

Thanks,

Tom
0 Kudos
2 Replies
AndyGup
Esri Regular Contributor
Tom,

Sorry for the delayed response. I've seen this happen in instances where there were multiple LocationService/LocationManager instances created. LocationManager can only have a single instance running or you won't be able to shut it off and hence turn it back on.

Here's a link to the EsriQuickStart which shows an advanced way of managing, starting and stopping location services: https://github.com/Esri/quickstart-map-android/blob/master/EsriQuickStart/src/com/esri/quickstart/Es.... Look at stopLocationService() starting at line 656, and delayedStartLocationService() starting at line 753.

I've also built an Android GPS Tool where you can test various scenarios, especially if you are having issues and need to compare/contrast settings: https://github.com/Esri/android-gps-test-tool

-Andy
0 Kudos
AndyGup
Esri Regular Contributor
Tom,

I almost forgot. Here's a blog post specifically about shutting down Android GPS: http://www.andygup.net/3-steps-for-shutting-off-gps-and-locationmanager-on-android/

-Andy
0 Kudos