Skip to content

Commit

Permalink
Register the broadcast with receiver flag
Browse files Browse the repository at this point in the history
  • Loading branch information
tr4n committed Dec 16, 2024
1 parent c3184da commit 740222d
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.maplibre.android.plugins.offline.offline;

import android.annotation.SuppressLint;
import android.app.Service;
import android.content.Intent;
import android.content.IntentFilter;
Expand Down Expand Up @@ -49,6 +50,7 @@ public class OfflineDownloadService extends Service {
// in OfflineDownloadOptions
final LongSparseArray<OfflineRegion> regionLongSparseArray = new LongSparseArray<>();

@SuppressLint("UnspecifiedRegisterReceiverFlag")
@Override
public void onCreate() {
super.onCreate();
Expand All @@ -62,7 +64,11 @@ public void onCreate() {
// Register the broadcast receiver needed for updating APIs in the OfflinePlugin class.
broadcastReceiver = new OfflineDownloadStateReceiver();
IntentFilter filter = new IntentFilter(OfflineConstants.ACTION_OFFLINE);
getApplicationContext().registerReceiver(broadcastReceiver, filter);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
getApplicationContext().registerReceiver(broadcastReceiver, filter, Context.RECEIVER_NOT_EXPORTED);
} else {
getApplicationContext().registerReceiver(broadcastReceiver, filter);
}
}

/**
Expand Down

0 comments on commit 740222d

Please sign in to comment.