Skip to content

Commit

Permalink
Remove locationListener when last widget is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
woheller69 committed Jun 1, 2021
1 parent d666f6d commit 6f629e2
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ public void onProviderDisabled(String provider) {

@Override
public void onDeleted(Context context, int[] appWidgetIds) {

}

@Override
Expand Down Expand Up @@ -227,6 +226,10 @@ public void onEnabled(Context context) {
@Override
public void onDisabled(Context context) {
// Enter relevant functionality for when the last widget is disabled
Log.d("GPS", "Last widget removed");
if (locationManager==null) locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
if (locationListenerGPS!=null) locationManager.removeUpdates(locationListenerGPS);
locationListenerGPS=null;
}

}
Expand Down

0 comments on commit 6f629e2

Please sign in to comment.