Check if Location is unavailable in Android Locati

2019-09-01 10:31发布

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?

2条回答
时光不老,我们不散
2楼-- · 2019-09-01 10:50

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

查看更多
啃猪蹄的小仙女
3楼-- · 2019-09-01 10:51

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.

查看更多
登录 后发表回答