[Android] Prevent crashes by using the broadcast receiver compat extension
Nicolas Pomepuy
git at videolan.org
Thu Jan 11 12:38:49 UTC 2024
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Jan 10 10:01:49 2024 +0100| [c5e3d91cdce6465db8f6b702781934407d12408e] | committer: Duncan McNamara
Prevent crashes by using the broadcast receiver compat extension
> https://code.videolan.org/videolan/vlc-android/commit/c5e3d91cdce6465db8f6b702781934407d12408e
---
.../main/java/org/videolan/mobile/app/delegates/IIndexersDelegate.kt | 4 ++--
.../vlc-android/src/org/videolan/vlc/util/VLCDownloadManager.kt | 3 ++-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/application/app/src/main/java/org/videolan/mobile/app/delegates/IIndexersDelegate.kt b/application/app/src/main/java/org/videolan/mobile/app/delegates/IIndexersDelegate.kt
index 28ce53c13a..ff8d75e04d 100644
--- a/application/app/src/main/java/org/videolan/mobile/app/delegates/IIndexersDelegate.kt
+++ b/application/app/src/main/java/org/videolan/mobile/app/delegates/IIndexersDelegate.kt
@@ -7,8 +7,8 @@ import android.content.IntentFilter
import kotlinx.coroutines.launch
import org.videolan.moviepedia.MediaScraper
import org.videolan.resources.ACTION_CONTENT_INDEXING
+import org.videolan.resources.util.registerReceiverCompat
import org.videolan.tools.AppScope
-import org.videolan.tools.localBroadcastManager
internal interface IIndexersDelegate {
fun Context.setupIndexers()
@@ -17,7 +17,7 @@ internal interface IIndexersDelegate {
internal class IndexersDelegate : BroadcastReceiver(), IIndexersDelegate {
override fun Context.setupIndexers() {
- localBroadcastManager.registerReceiver(this at IndexersDelegate, IntentFilter(ACTION_CONTENT_INDEXING))
+ registerReceiverCompat(this at IndexersDelegate, IntentFilter(ACTION_CONTENT_INDEXING), false)
}
override fun onReceive(context: Context?, intent: Intent?) {
diff --git a/application/vlc-android/src/org/videolan/vlc/util/VLCDownloadManager.kt b/application/vlc-android/src/org/videolan/vlc/util/VLCDownloadManager.kt
index 2bf96ba090..9b5271deba 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/VLCDownloadManager.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/VLCDownloadManager.kt
@@ -17,6 +17,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.videolan.libvlc.util.Extensions
import org.videolan.resources.AppContextProvider
+import org.videolan.resources.util.registerReceiverCompat
import org.videolan.tools.isStarted
import org.videolan.vlc.R
import org.videolan.vlc.gui.dialogs.SubtitleItem
@@ -48,7 +49,7 @@ object VLCDownloadManager: BroadcastReceiver(), DefaultLifecycleObserver {
}
override fun onStart(owner: LifecycleOwner) {
- AppContextProvider.appContext.applicationContext.registerReceiver(this, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE))
+ AppContextProvider.appContext.applicationContext.registerReceiverCompat(this, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE), true)
}
override fun onDestroy(owner: LifecycleOwner) {
More information about the Android
mailing list