From 59caecf7172702479585cd6de631b5d44bd0ade0 Mon Sep 17 00:00:00 2001 From: DeLoooping Date: Sat, 14 Dec 2024 15:53:55 +0000 Subject: [PATCH] fix calendar synchronization (#4403) Reviewed-on: https://codeberg.org/Freeyourgadget/Gadgetbridge/pulls/4403 Co-authored-by: DeLoooping Co-committed-by: DeLoooping --- .../gadgetbridge/externalevents/CalendarReceiver.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CalendarReceiver.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CalendarReceiver.java index d835c4c64..0b0689b67 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CalendarReceiver.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CalendarReceiver.java @@ -18,6 +18,8 @@ package nodomain.freeyourgadget.gadgetbridge.externalevents; +import static androidx.core.content.ContextCompat.RECEIVER_NOT_EXPORTED; + import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -28,7 +30,7 @@ import android.os.Handler; import android.provider.CalendarContract; import android.widget.Toast; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; +import androidx.core.content.ContextCompat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -110,7 +112,7 @@ public class CalendarReceiver extends ContentObserver { mContext.getContentResolver().registerContentObserver(CalendarContract.Events.CONTENT_URI, true, this); // Add a receiver to allow us to quickly force as calendar sync (without having to provide data) - LocalBroadcastManager.getInstance(mContext).registerReceiver(mForceSyncReceiver, new IntentFilter(ACTION_FORCE_SYNC)); + ContextCompat.registerReceiver(mContext, mForceSyncReceiver, new IntentFilter(ACTION_FORCE_SYNC), RECEIVER_NOT_EXPORTED); } public GBDevice getGBDevice() { @@ -265,7 +267,7 @@ public class CalendarReceiver extends ContentObserver { public void dispose() { mContext.getContentResolver().unregisterContentObserver(this); - LocalBroadcastManager.getInstance(mContext).unregisterReceiver(mForceSyncReceiver); + mContext.unregisterReceiver(mForceSyncReceiver); mSyncHandler.removeCallbacksAndMessages(null); }