[Android] Prevent NPE

Geoffrey Métais git at videolan.org
Wed Jul 26 11:33:08 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jul 26 10:44:37 2017 +0200| [1cdf97fcf18096fadd1667387052269c9fd5e777] | committer: Geoffrey Métais

Prevent NPE

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

 vlc-android/src/org/videolan/vlc/gui/MainActivity.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 08299258d..0bb1c795b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -136,7 +136,8 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
         if (savedInstanceState != null) {
             //Restore fragments stack
             for (Fragment fragment : getSupportFragmentManager().getFragments())
-                mFragmentsStack.put(fragment.getTag(), new WeakReference<>(fragment));
+                if (fragment != null)
+                    mFragmentsStack.put(fragment.getTag(), new WeakReference<>(fragment));
 
             mCurrentFragmentId = savedInstanceState.getInt("current");
             if (mCurrentFragmentId > 0) {



More information about the Android mailing list