onProviderEnabled(Stringprovider) 方法中传入的实际字符串是什么?
假设您有一个位置侦听器,它可能正在侦听来自网络提供商的位置更新。我希望每当用户启用 GPS 时,我的侦听器就停止使用网络并开始从 GPS 侦听。
我的理解是,每当启用提供程序时,它都会向 onProviderEnabled() 方法发送一条消息,并传入一个带有其名称的字符串。
GPS 传入的实际值是多少?是“GPS”、“gps”还是“GPS_PROVIDER”?
谢谢迈克
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SDK 文档提供了每个定义常量的字符串文字的当前值:
http ://developer.android.com/reference/android/location/LocationManager.html#GPS_PROVIDER
您可以看到,当前
LocationManager.GPS_PROVIDER
的值为“gps”。但是,在代码中,您应该始终通过常量LocationManager.GPS_PROVIDER
引用该值。希望有帮助!
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 constantLocationManager.GPS_PROVIDER
.Hope that Helps!