Check if Location is unavailable in Android Location Client

非 Y 不嫁゛ 提交于 2019-12-13 04:37:49

问题


I would like to check if Location Client is able to provide any location. Is there any way to do so, apart from calling normal location system service?


回答1:


The accepted answer was correct at the time. But in recent times things have changed with the availability of the SettingsApi It allows you to check if the location services are available on the device and there is a complete example provided by google on github that shows how to use this API. The sample code will prompt the user to enable location if it's switched off.




回答2:


AFAIK, there is no method to check availability.

Possible Reason:

LocationClient uses fused API which gives location with appropriate combination of GPS,WiFi,Cell,Sensors (according to the Priority you have set for retrieving location).

Reference:

Fused API - Beyond the blue dot

Alternate Solution:

You already know it.you can check availability of provider by using location system service and LocationManager



来源:https://stackoverflow.com/questions/17041010/check-if-location-is-unavailable-in-android-location-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!