Skip to content

Commit

Permalink
fix: register Bluetooth and USB receivers using RECEIVER_EXPORTED flag
Browse files Browse the repository at this point in the history
https://developer.android.com/develop/background-work/background-tasks/broadcasts#context-registered-receivers

Note from Step 4.:
"Some system broadcasts come from highly privileged apps, such as Bluetooth and telephony, that are part of the Android framework but do not run under the system's unique process ID (UID). To receive all system broadcasts, including broadcasts from highly privileged apps, flag your receiver with RECEIVER_EXPORTED."
  • Loading branch information
andrekir committed Aug 3, 2024
1 parent b4221c7 commit ca537be
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fun PackageManager.getPackageInfoCompat(packageName: String, flags: Int = 0): Pa
fun Context.registerReceiverCompat(
receiver: BroadcastReceiver,
filter: IntentFilter,
flag: Int = ContextCompat.RECEIVER_NOT_EXPORTED,
flag: Int = ContextCompat.RECEIVER_EXPORTED,
) {
ContextCompat.registerReceiver(this, receiver, filter, flag)
}
Expand Down

0 comments on commit ca537be

Please sign in to comment.