[Android] MainActivity: Fix an IllegalStateException
Ludovic Fauvet
git at videolan.org
Thu Oct 11 12:48:11 CEST 2012
vlc-ports/android | branch: master | Ludovic Fauvet <etix at videolan.org> | Wed Oct 10 16:55:11 2012 +0200| [46ece7f58198993642afeca46849dcffe36c1d5f] | committer: Ludovic Fauvet
MainActivity: Fix an IllegalStateException
"Can not perform this action after onSaveInstanceState"
Using the support/compat library, fragments *must* be restored in
onResumeFragments and not onResume.
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=46ece7f58198993642afeca46849dcffe36c1d5f
---
vlc-android/src/org/videolan/vlc/gui/MainActivity.java | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 83d4300..0889327 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -285,6 +285,17 @@ public class MainActivity extends SherlockFragmentActivity {
if (getIntent().hasExtra(AudioService.START_FROM_NOTIFICATION))
getIntent().removeExtra(AudioService.START_FROM_NOTIFICATION);
+ /* Load media items from database and storage */
+ if (mScanNeeded)
+ MediaLibrary.getInstance(this).loadMediaItems(this);
+ }
+
+
+
+ @Override
+ protected void onResumeFragments() {
+ super.onResumeFragments();
+
/* Restore last view */
Fragment current = getSupportFragmentManager()
.findFragmentById(R.id.fragment_placeholder);
@@ -308,10 +319,6 @@ public class MainActivity extends SherlockFragmentActivity {
ft.replace(R.id.fragment_placeholder, getFragment(mCurrentFragment));
ft.commit();
}
-
- /* Load media items from database and storage */
- if (mScanNeeded)
- MediaLibrary.getInstance(this).loadMediaItems(this);
}
/**
More information about the Android
mailing list