From 9dbab7d90cb2b827f152c391c55808c5881f0a3a Mon Sep 17 00:00:00 2001 From: Hai Zhang Date: Sun, 10 Sep 2023 04:16:17 -0700 Subject: [PATCH] [Feature] Target Android 14. Add foreground service types and specify exported flag when register receivers. --- app/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 8 ++++++-- .../android/files/storage/StorageVolumeListLiveData.kt | 6 ++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 258a91c06..08ee53190 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -34,7 +34,7 @@ android { minSdk 21 // Not supporting notification runtime permission yet. //noinspection OldTargetApi - targetSdk 33 + targetSdk 34 versionCode 33 versionName '1.6.1' resValue 'string', 'app_version', versionName + ' (' + versionCode + ')' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 87e66a657..f7b28e0f8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -17,6 +17,7 @@ + - + - + >() { init { loadValue() - application.registerReceiver( + application.registerReceiverCompat( object : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { loadValue() @@ -36,7 +38,7 @@ object StorageVolumeListLiveData : LiveData>() { // The "file" data scheme is required to receive these broadcasts. // @see https://stackoverflow.com/a/7143298 addDataScheme(ContentResolver.SCHEME_FILE) - } + }, ContextCompat.RECEIVER_NOT_EXPORTED ) }