MyLocationOverlay does not call onProviderDisabled

This is my code that behaves a bit strange:

locationOverlay = new MyLocationOverlay(this, map) { @Override public void onLocationChanged(Location location) { super.onLocationChanged(location); updatePosition(locationOverlay.getMyLocation()); } @Override public void onProviderDisabled(String provider) { if(provider.equals(LocationManager.GPS_PROVIDER)) showNoGPSWarning(); } }; 

showNoGPSWarning displays a dialog that asks if GPS must be enabled (for example this ).
Everything wokr is fine, unless I start Activity with GPS turned off and click "No" in the showNoGPSWarning() dialog box. Then my application does not listen to GPS changes at all.

If I turn it on, nothing will happen. The Google Maps API is not trying to receive a GPS signal. If I disable it, nothing will happen again, onProviderDisabled() not called.
As I said, this is the only way that happens if I click "Yes" in the dialog box in which it works.
So how does my dialogue affect the behavior of my application ?.

0
source share
1 answer

Try to request location updates again when clicking yes / no, as shown below. Hope this helps.

 locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 2000.0f, myLocationListener); 
+1
source

Source: https://habr.com/ru/post/1434569/


All Articles