[Android] Prevent IllegalStateException in permissions fragment

Geoffrey Métais git at videolan.org
Wed Nov 29 15:17:56 CET 2017


vlc-android | branch: 2.5.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Nov 29 15:04:57 2017 +0100| [193951d391876c9396876c1b4f2cc7b668b286e7] | committer: Geoffrey Métais

Prevent IllegalStateException in permissions fragment

(cherry picked from commit af962ea33e447a1e79bff36efdae267d812ae886)

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

 .../org/videolan/vlc/gui/helpers/hf/StoragePermissionsDelegate.java  | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/hf/StoragePermissionsDelegate.java b/vlc-android/src/org/videolan/vlc/gui/helpers/hf/StoragePermissionsDelegate.java
index 7ade4e5bc..3cf5fef25 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/hf/StoragePermissionsDelegate.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/hf/StoragePermissionsDelegate.java
@@ -104,10 +104,11 @@ public class StoragePermissionsDelegate extends BaseHeadlessFragment {
     }
 
     public static void askStoragePermission(@NonNull FragmentActivity activity) {
+        if (activity.isFinishing()) return;
         final FragmentManager fm = activity.getSupportFragmentManager();
-        Fragment fragment = fm.findFragmentByTag(TAG);
+        final Fragment fragment = fm.findFragmentByTag(TAG);
         if (fragment == null)
-            fm.beginTransaction().add(new StoragePermissionsDelegate(), TAG).commit();
+            fm.beginTransaction().add(new StoragePermissionsDelegate(), TAG).commitAllowingStateLoss();
         else
             ((StoragePermissionsDelegate)fragment).requestStorageAccess();
     }



More information about the Android mailing list