Check if Location is unavailable in Android Locati

2019-09-01 10:48发布

问题:

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