[Android] ExternalMonitor: catch IllegalArgumentException

Geoffrey Métais git at videolan.org
Tue Oct 1 14:44:41 CEST 2019


vlc-android | branch: 3.2.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Sep 30 10:37:56 2019 +0200| [f8bbdf3283141727d58260af4cd77d832ecf7006] | committer: Geoffrey Métais

ExternalMonitor: catch IllegalArgumentException

Sometimes, broadcast listener registering is saved but not valid

(cherry picked from commit 993287262e00c4fe633ada29cfe5188adec57658)

> https://code.videolan.org/videolan/vlc-android/commit/f8bbdf3283141727d58260af4cd77d832ecf7006
---

 vlc-android/src/org/videolan/vlc/ExternalMonitor.kt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/ExternalMonitor.kt b/vlc-android/src/org/videolan/vlc/ExternalMonitor.kt
index 2019e2004..74adde90f 100644
--- a/vlc-android/src/org/videolan/vlc/ExternalMonitor.kt
+++ b/vlc-android/src/org/videolan/vlc/ExternalMonitor.kt
@@ -190,7 +190,9 @@ object ExternalMonitor : BroadcastReceiver(), LifecycleObserver, CoroutineScope
     @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
     internal fun unregister() {
         val ctx = VLCApplication.appContext
-        if (registered) ctx.unregisterReceiver(this)
+        if (registered) try {
+            ctx.unregisterReceiver(this)
+        } catch (iae: IllegalArgumentException) {}
         registered = false
         connected.value = false
         devices.clear()



More information about the Android mailing list