use ContextCompat for BRs

This commit is contained in:
Adam Velebil 2023-04-11 16:28:58 +02:00
parent 140554146d
commit 9e7251c695
No known key found for this signature in database
GPG Key ID: C9B1E4A3CBBD2E10
3 changed files with 23 additions and 2 deletions

View File

@ -99,6 +99,7 @@ dependencies {
// Lifecycle
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1'
implementation 'androidx.core:core-ktx:1.10.0'
implementation 'androidx.fragment:fragment-ktx:1.5.6'
implementation 'androidx.preference:preference-ktx:1.2.0'

View File

@ -4,6 +4,14 @@
<uses-permission android:name="android.permission.NFC" />
<uses-permission
android:name="${applicationId}.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION"
tools:node="remove" />
<permission
android:name="${applicationId}.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION"
tools:node="remove" />
<uses-feature
android:name="android.hardware.usb.host"
android:required="false" />

View File

@ -35,6 +35,8 @@ import android.os.Bundle
import android.provider.Settings.ACTION_NFC_SETTINGS
import android.view.WindowManager
import androidx.activity.viewModels
import androidx.core.content.ContextCompat
import androidx.core.content.ContextCompat.RECEIVER_NOT_EXPORTED
import androidx.core.view.WindowCompat
import androidx.lifecycle.lifecycleScope
import com.yubico.authenticator.logging.FlutterLog
@ -168,8 +170,18 @@ class MainActivity : FlutterFragmentActivity() {
override fun onStart() {
super.onStart()
registerReceiver(qrScannerCameraClosedBR, QRScannerCameraClosedBR.intentFilter)
registerReceiver(nfcAdapterStateChangeBR, NfcAdapterStateChangedBR.intentFilter)
ContextCompat.registerReceiver(
this,
qrScannerCameraClosedBR,
QRScannerCameraClosedBR.intentFilter,
RECEIVER_NOT_EXPORTED
)
ContextCompat.registerReceiver(
this,
nfcAdapterStateChangeBR,
NfcAdapterStateChangedBR.intentFilter,
RECEIVER_NOT_EXPORTED
)
}
override fun onStop() {