BroadcastReceiver se dispara varias veces (PROVIDERS_CHANGED_ACTION)
¿Por qué BroadcastReceiver
fue desencadenar varias veces.
Mi proyecto de muestra es como debajo del código
- ¿Puede el servicio de una aplicación Android ejecutarse antes de que el usuario lo inicie?
- ACTION_MY_PACKAGE_REPLACED no recibido
- BroadcastReceiver onReceive no se llama
- BroadcastReceiver nunca llamó
- Descartar la notificación de Android en curso mediante el botón de acción sin abrir la aplicación
ANDROID MANIFEST
<receiver android:name=".LocationProvideListener" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.location.PROVIDERS_CHANGED"/> </intent-filter> </receiver>
RECEPTOR BBROADCAST
public class LocationProvideListener extends BroadcastReceiver { private static final String TAG = "LocationProvideListener"; @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().matches(LocationManager.PROVIDERS_CHANGED_ACTION)) { // react on GPS provider change action LocationManager manager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); boolean isNetwork = manager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); boolean isGPS = manager.isProviderEnabled(LocationManager.GPS_PROVIDER); Log.e(TAG, "IsNetwork = " + (isNetwork ? "true" : "false")); Log.e(TAG, "IsGPS = " + (isGPS ? "true" : "false")); } } }
REGISTRO (CUANDO ENCENDE LA UBICACIÓN)
07-22 12:09:47.275 22176-22176/com.example.checkLocationProvider E/LocationProvideListener﹕ IsNetwork = false 07-22 12:09:47.275 22176-22176/com.example.checkLocationProvider E/LocationProvideListener﹕ IsGPS = true 07-22 12:09:47.778 22176-22176/com.example.checkLocationProvider E/LocationProvideListener﹕ IsNetwork = false 07-22 12:09:47.778 22176-22176/com.example.checkLocationProvider E/LocationProvideListener﹕ IsGPS = true 07-22 12:09:48.115 22176-22176/com.example.checkLocationProvider E/LocationProvideListener﹕ IsNetwork = false 07-22 12:09:48.115 22176-22176/com.example.checkLocationProvider E/LocationProvideListener﹕ IsGPS = true
REGISTRO (CUANDO ACEPTA LA PERMISIÓN)
07-22 12:09:55.412 22176-22176/com.example.checkLocationProvider E/LocationProvideListener﹕ IsNetwork = true 07-22 12:09:55.412 22176-22176/com.example.checkLocationProvider E/LocationProvideListener﹕ IsGPS = true
REGISTRO (CUANDO APAGUE LA UBICACIÓN)
07-22 12:10:04.856 22176-22176/com.example.checkLocationProvider E/LocationProvideListener﹕ IsNetwork = false 07-22 12:10:04.856 22176-22176/com.example.checkLocationProvider E/LocationProvideListener﹕ IsGPS = false 07-22 12:10:04.941 22176-22176/com.example.checkLocationProvider E/LocationProvideListener﹕ IsNetwork = false 07-22 12:10:04.941 22176-22176/com.example.checkLocationProvider E/LocationProvideListener﹕ IsGPS = false
- Cómo atrapar el sistema de difusión BOOT_COMPLETED, mi programa simplemente no funciona?
- Utilizar el receptor de difusión para capturar la llamada entrante, onReceive no activado?
- Detección de cambios en el tipo de red (TelephonyManager) en android
- ¿Cómo identifica * qué * dispositivo bluetooth causa una emisión ACTION_ACL_CONNECTED?
- Cómo cancelar el registro de BroadcastReceiver
- ¿Es posible escribir un receptor de difusión Android que detecte cuando el teléfono se despierta?
- La detección de cambios de estado de la red Android tarda tiempo
- Java.lang.InstantiationException: class no tiene constructor de argumento cero
- La actualización de la aplicación pierde todos los datos como ruta Código / Resouce para los cambios de pkg
- Uri no está registrado para el diseño en recursos de prueba