1.1: It’s better to stop listening to GPS when your application is paused or stopped (onPause () and onStop ()). This will save battery life. So, run the receiver again in the onResume () method.
removeUpdates (locationListener)
If you do not want to removeUpdates, you do not need to call location locationManager.requestLocationUpdates again.
1.2. When the application comes to the forefront, check isProviderEnabled (the provider) and show the dialog to the user.
To answer your question:
https://developer.android.com/reference/android/location/LocationManager.html
If the provider is disabled by the user, updates will cease and a supplier availability update will be sent. As soon as the provider is turned on again, location updates will resume immediately and a supplier availability update will be sent. Suppliers can also send status updates at any time with additional data for the provider. If a callback was received, then state and availability updates are available via onProviderDisabled (String), onProviderEnabled (String) or onStatusChanged (String, int, Bundle).
- Your application may crash if permission is revoked. Because you will not have access to the location function.
java.lang.SecurityException: ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION permission is required for the provider network
- In multi-window devices, one application that is focused will be able to resume, another application will be paused. And regarding recall recall, I answered in paragraph 2.
If the location is disconnected from the settings, third-party applications will not be notified about this. To check the status of the location you need to use the isProviderEnabled method (provider).
source share