[Android] Prevent NPE when removable storage is not found

Geoffrey Métais git at videolan.org
Fri Mar 30 16:51:20 CEST 2018


vlc-android | branch: 3.0.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Mar 22 10:33:42 2018 +0100| [1c1a42c4c9e47517472a66c3a9c9938d680bc750] | committer: Geoffrey Métais

Prevent NPE when removable storage is not found

(cherry picked from commit 13a123e6e898717de9c24229c519adb527bad603)

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

 .../src/org/videolan/vlc/gui/helpers/hf/WriteExternalDelegate.kt        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/hf/WriteExternalDelegate.kt b/vlc-android/src/org/videolan/vlc/gui/helpers/hf/WriteExternalDelegate.kt
index 99dd48d6a..89e3595bd 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/hf/WriteExternalDelegate.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/hf/WriteExternalDelegate.kt
@@ -92,7 +92,7 @@ class WriteExternalDelegate : BaseHeadlessFragment() {
             if (activity === null) return
             val fragment = WriteExternalDelegate()
             callback = cb
-            storage = FileUtils.getMediaStorage(uri)
+            storage = FileUtils.getMediaStorage(uri) ?: return
             fragment.arguments = Bundle(1).apply { putString(KEY_STORAGE_PATH, storage) }
             activity.supportFragmentManager.beginTransaction().add(fragment, TAG).commitAllowingStateLoss()
         }



More information about the Android mailing list