与播放业务定位API允许Android的检查位置服务位置、业务、API、Android

2023-09-04 08:19:09 作者:おうじゃ (王者)

您可以确定是否有任何供应商都可以使用LocationManager,但它与谷歌播放业务定位API来完成?

You can determine if any providers are available with LocationManager, but can it be done with the google play services location api?

在没有启用,其实访问我的位置功能关闭,所有API调用(connect()的,requestLocationUpdates())成功,但你永远不会得到一个onLocationChanged()。

When nothing is enabled, in fact "access to my location" is off, all the API calls (connect(), requestLocationUpdates()) succeed, but you never get an onLocationChanged().

看来愚蠢不得不同时使用LocationManager和LocationClient。

Seems silly to have to use both LocationManager and the LocationClient.

我想我需要的是一些方法来知道onLocationChanged(0会的永远的调用。

I guess what I need is some way to know that onLocationChanged(0 will never get called.

推荐答案

我梳理了文档,也没有发现任何方式使用LocationClient如果启用了定位服务来检测。 onConnected,onDisconnected和onConnectionFailed似乎并没有被链接到位置服务是否启用与否。

I've combed the docs and also haven't found any way to use LocationClient to detect if location services are enabled. onConnected, onDisconnected, and onConnectionFailed do not seem to be linked to whether Location Services are enabled or not.

我目前做的使用LocationClient位置请求,但使用旧 locationManager.isProviderEnabled(字符串提供商)方法,如果启用了定位服务来检测。这是最适合我的,因为,即使LocationClient确实提供了一种方法,它使全球定位系统和网络之间没有区别,我真的很希望能够要求用户启用GPS。

I'm currently doing location requests using LocationClient, but using the old locationManager.isProviderEnabled(String provider) method to detect if the Location Services are enabled. This is optimal for me, as, even if LocationClient did provide a way, it makes no distinction between GPS and Network and I'd really like to be able to request that the user enable GPS.

if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { 
    //GPS Provider disabled
    return false;
}