Search code examples
androidgeolocationgpslocationlistener

What is the actual string that is passed in in the onProviderEnabled(String provider) method?


suppose you have a location listener that might be listening for location updates from the network provider. I want whenever the user enables GPS my listener to stop using network and start listening from the GPS.

My understanding is that whenever a provider is enabled it sends a message to the onProviderEnabled() method passing in a string with its name.

What is the actual value that is passed in for GPS? Is it "GPS", "gps" or "GPS_PROVIDER"?

Thanks

Mike


Solution

  • The SDK documentation provides the current value of the String literals for each defined constant:

    http://developer.android.com/reference/android/location/LocationManager.html#GPS_PROVIDER

    You can see that currently the value for LocationManager.GPS_PROVIDER is "gps". However, in code you should always refer to this value by its constant LocationManager.GPS_PROVIDER.

    Hope that Helps!