开发者

How can I determine whether GPS is available? Also, how can I determine city/state/country based on GPS coordinates?

开发者 https://www.devze.com 2023-01-24 05:39 出处:网络
I have a few little questions regarding GPS in Android: How can I determine whether GPS is available on the device?

I have a few little questions regarding GPS in Android:

  1. How can I determine whether GPS is available on the device?

  2. I found several links for determining the coordinates of the current location开发者_JS百科. Is there any way to determine the city/state/country based on these coordinates?


To your first question. You can try to get a certain LocationProvider by calling the getProvider() method of the LocationManager. If the requested provider is available it returns the LocationProvider if not it returns null.

Your second question. Yes you can do that with the GeoCoder. By calling the getFromLocation() method and passing it the latitude, longitude and a value for the maximum addresses you'd like to obtain.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号