Well, I found one way to check if the "Location
" setting of the action bar
is enabled or disabled; but without a BroadcastReceiver
(a shame, really)
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);
}
I really did not need a BroadcastReceiver
; since the "arquitecture" that has my app allows me to do without it; but I would have liked to know how to use it.
NOTICE:
If someone finds the way to make it with a BroadcastReceiver
I will change my correct answer by her answer.