【发布时间】:2014-09-29 04:29:51
【问题描述】:
据我们所知,我们有两个替代方案可以让我们的应用程序知道位置 我们要么使用 Google 的 Location Services API(Google Play 服务的一部分),要么使用 Androids Location API。
我在这里遇到的问题是,使用 Google 的服务,我们必须使用接口 com.google.android.gms.location.LocationListener 为我们提供位置更新。 然而,与 android.location.LocationListener 不同的是,google 的版本并没有向我们提供位置提供者(gps 或互联网)的状态。
我们在 Androids Location Listener 中有以下方法
abstract void onLocationChanged(Location location)
Called when the location has changed.
abstract void onProviderDisabled(String provider)
Called when the provider is disabled by the user.
abstract void onProviderEnabled(String provider)
Called when the provider is enabled by the user.
abstract void onStatusChanged(String provider, int status, Bundle extras)
Called when the provider status changes
.
但是在谷歌我们只有一个
abstract void onLocationChanged(Location location)
如果我使用谷歌服务,我如何识别提供者的变化? .例如,在应用程序使用过程中,用户决定关闭 GPS,我想在此事件上举杯。
我在黑暗中应该如何实现这一点。
【问题讨论】: