make sure we stop updates when we're supposed to

This commit is contained in:
Tom Hennen 2015-11-29 12:07:29 -05:00
parent 1268d8f6c7
commit e9f46bd71d
2 changed files with 18 additions and 1 deletions

View File

@ -40,6 +40,18 @@ public class PlayerWidget extends AppWidgetProvider {
startUpdate(context); startUpdate(context);
} }
@Override
public void onDisabled(Context context) {
super.onDisabled(context);
stopUpdate(context);
}
@Override
public void onDeleted(Context context, int[] appWidgetIds) {
super.onDeleted(context, appWidgetIds);
stopUpdate(context);
}
private void startUpdate(Context context) { private void startUpdate(Context context) {
Log.d(TAG, "startUpdate() called with: " + "context = [" + context + "]"); Log.d(TAG, "startUpdate() called with: " + "context = [" + context + "]");
context.startService(new Intent(context, PlayerWidgetService.class)); context.startService(new Intent(context, PlayerWidgetService.class));

View File

@ -1,4 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:resizeMode="none" android:initialLayout="@layout/player_widget" android:minHeight="40dp" android:minWidth="250dp"> <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:resizeMode="none"
android:initialLayout="@layout/player_widget"
android:updatePeriodMillis="600000"
android:minHeight="40dp"
android:minWidth="250dp">
</appwidget-provider> </appwidget-provider>