Skip to content

Commit ecdd49d

Browse files
committed
keep preference listener to react to consent change
The change of the consent flag happens in a dialog, i.e. when the main activity is paused. To still react to this and register the network callback during initialization, we need to keep the change listener registered. It should be fine to only unregister on destroy: if the process is really killed, then the shared preferences instance will also be gone, so it should not matter that we did not call unregister on it.
1 parent 2005efe commit ecdd49d

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

app/src/main/java/org/ostrya/presencepublisher/MainActivity.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,12 @@ public void onCreate(Bundle savedInstanceState) {
5555
@Override
5656
protected void onResume() {
5757
super.onResume();
58-
sharedPreferences.registerOnSharedPreferenceChangeListener(sharedPreferenceListener);
5958
handler.initialize();
6059
}
6160

62-
@Override
63-
protected void onPause() {
64-
super.onPause();
65-
sharedPreferences.unregisterOnSharedPreferenceChangeListener(sharedPreferenceListener);
66-
}
67-
6861
@Override
6962
protected void onDestroy() {
63+
sharedPreferences.unregisterOnSharedPreferenceChangeListener(sharedPreferenceListener);
7064
super.onDestroy();
7165
handler = null;
7266
}

0 commit comments

Comments
 (0)