Skip to content

Commit

Permalink
fix: Move AppWidgetHost listening to onStart/onStop
Browse files Browse the repository at this point in the history
fully fixes #2
  • Loading branch information
ns130291 committed Jun 14, 2023
1 parent 5f7b493 commit 809cf79
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId "de.nsvb.android.auto.widget"
minSdkVersion 21
targetSdkVersion 33
versionCode 3
versionName "0.2.1"
versionCode 4
versionName "0.2.2"
}

ext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected void onCreate(Bundle savedInstanceState) {
"aauto-sdk-demo by martoreto<br>" +
"<a href=\"https://github.com/martoreto/aauto-sdk-demo\">https://github.com/martoreto/aauto-sdk-demo</a><br><br>" +
"Widget Host Example by Leonardo Fischer<br>" +
"<a href=\"https://github.com/lgfischer/WidgetHostExample\">https://github.com/lgfischer/WidgetHostExample</a>" +
"<a href=\"https://github.com/lgfischer/WidgetHostExample\">https://github.com/lgfischer/WidgetHostExample</a><br><br>" +
"KISS by Neamar<br>" +
"<a href=\"https://github.com/Neamar/KISS\">https://github.com/Neamar/KISS</a>"));
tv.setMovementMethod(LinkMovementMethod.getInstance());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,23 @@ public void onClick(View view) {
}

@Override
protected void onResume() {
super.onResume();
mAppWidgetHost.startListening();
}

@Override
protected void onPause() {
super.onPause();

mAppWidgetHost.stopListening();
protected void onStart() {
super.onStart();
try {
mAppWidgetHost.startListening();
} catch (Exception e) {
Log.e(TAG, "couldn't start listening for widget updates:", e);
}
}

@Override
protected void onStop() {
super.onStop();


try {
mAppWidgetHost.stopListening();
} catch (Exception e) {
Log.w(TAG, "couldn't stop listening for widget updates:", e);
}
}

public void selectWidget() {
Expand Down

0 comments on commit 809cf79

Please sign in to comment.