From 20781ddafe49fb3d5872dada615e949f2a28ef5c Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Sun, 11 Feb 2024 18:21:10 +1300 Subject: [PATCH] Fix registering receiver warnings in BackupModule.kt --- .../app/src/main/java/com/massive/BackupModule.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/java/com/massive/BackupModule.kt b/android/app/src/main/java/com/massive/BackupModule.kt index ef365c6..226f38c 100644 --- a/android/app/src/main/java/com/massive/BackupModule.kt +++ b/android/app/src/main/java/com/massive/BackupModule.kt @@ -1,5 +1,6 @@ package com.massive +import android.annotation.SuppressLint import android.app.AlarmManager import android.app.PendingIntent import android.content.* @@ -15,7 +16,8 @@ import com.facebook.react.bridge.ReactMethod import java.io.* import java.util.* -class BackupModule constructor(context: ReactApplicationContext?) : +@SuppressLint("UnspecifiedRegisterReceiverFlag") +class BackupModule(context: ReactApplicationContext?) : ReactContextBaseJavaModule(context) { val context: ReactApplicationContext = reactApplicationContext @@ -87,7 +89,13 @@ class BackupModule constructor(context: ReactApplicationContext?) : } init { - reactApplicationContext.registerReceiver(copyReceiver, IntentFilter(COPY_BROADCAST)) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + reactApplicationContext.registerReceiver(copyReceiver, IntentFilter(COPY_BROADCAST), + Context.RECEIVER_NOT_EXPORTED) + } + else { + reactApplicationContext.registerReceiver(copyReceiver, IntentFilter(COPY_BROADCAST)) + } } companion object {