Google Play Location Service 的 BroadcastReceiver(状态栏的设置)

BroadcastReceiver for Google Play Location Service (setting of the Status Bar)

我正在尝试注册一个 BroadcastReceiver 以获取 Location 设置的状态变化

但我没有找到任何相关文档。我只找到 BroadcastReceiver 来检查某些搜索提供商的状态(GPSNetwork providers);但不用于检查此特定选项 (Location) 在系统首选项中是否处于活动状态。

有人可以告诉我正确的方向吗?


NOTE:

I used Google Play Location Service (com.google.android.gms.location.LocationListener interface).

好吧,我找到了一种方法来检查 action bar 的“Location”设置是启用还是禁用;但是没有一个BroadcastReceiver真可惜

private static final String TAG = getClass().getName();

/* We define the LocationManager */
LocationManager location_Manager= (LocationManager) getSystemService(LOCATION_SERVICE);

/* If the GPS provider or the network provider are enabled; the Location setting is enabled.*/
if(location_Manager.isProviderEnabled(LocationManager.GPS_PROVIDER) || location_Manager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
    Log.d(TAG, "The Location setting is enabled");
}else{
   /* We send the user to the "Location activity" to enable the setting */
   Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
   startActivity(intent);
}

我真的不需要BroadcastReceiver;因为有我的应用程序的“arquitecture”允许我没有它;但我很想知道如何使用它。

NOTICE:

If someone finds the way to make it with a BroadcastReceiver I will change my correct answer by her answer.

您可以尝试使用 Location Listener。

onProviderDisabled(String provider)
Called when the provider is disabled by the user.

与提供者字符串比较,例如
provider.equalsIgnoreCase(LocationManager.GPS_PROVIDER) http://developer.android.com/reference/android/location/LocationListener.html