Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register the broadcast with receiver flag #78

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.maplibre.android.plugins.offline.offline;

import android.annotation.SuppressLint;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
Expand Down Expand Up @@ -49,6 +51,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 +65,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