[Android] widgets manager: Prevent NPE

Geoffrey Métais git at videolan.org
Thu Aug 8 13:53:42 CEST 2019


vlc-android | branch: 3.2.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Aug  1 17:21:51 2019 +0200| [70706d40417b6ff206af8cfc7f8fa9d9ed2c7c65] | committer: Geoffrey Métais

widgets manager: Prevent NPE

(cherry picked from commit 23465078b45695246dfb0c7adfc64998abc64fa4)

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

 vlc-android/src/org/videolan/vlc/PlaybackService.kt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index e1ae26055..27c770517 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -484,7 +484,7 @@ class PlaybackService : MediaBrowserServiceCompat(), CoroutineScope, LifecycleOw
     }
 
     private fun updateHasWidget() {
-        val manager = AppWidgetManager.getInstance(this)
+        val manager = AppWidgetManager.getInstance(this) ?: return
         widget = when {
             manager.getAppWidgetIds(ComponentName(this, VLCAppWidgetProviderWhite::class.java)).isNotEmpty() -> 1
             manager.getAppWidgetIds(ComponentName(this, VLCAppWidgetProviderBlack::class.java)).isNotEmpty() -> 2



More information about the Android mailing list