[Android] MediaInfoFragment: avoid a crash accessing the Activity

Jean-Baptiste Kempf git at videolan.org
Sun Jul 6 08:24:10 CEST 2014


vlc-ports/android | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sun Jul  6 05:20:17 2014 +0200| [275ce179edebf221a8b1753217570ede8527a0f7] | committer: Jean-Baptiste Kempf

MediaInfoFragment: avoid a crash accessing the Activity

YOU SHALL NOT call getActivity before onActivityCreated() in a fragment

And of course, update() was called in onCreateView

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=275ce179edebf221a8b1753217570ede8527a0f7
---

 .../src/org/videolan/vlc/gui/video/MediaInfoFragment.java      |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
index d018da1..c9bf6c0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
@@ -79,11 +79,15 @@ public class MediaInfoFragment extends ListFragment {
         mAdapter = new MediaInfoAdapter(getActivity());
         setListAdapter(mAdapter);
 
-        update();
-
         return v;
     }
 
+    @Override
+    public void onActivityCreated(Bundle savedInstanceState) {
+        super.onActivityCreated(savedInstanceState);
+        update();
+    }
+
     public void setMediaLocation(String MRL) {
         if (MRL == null)
             return;



More information about the Android mailing list