[Android] Fix an IllegalStateException related to the onSaveInstanceState call

Ludovic Fauvet git at videolan.org
Tue Jul 3 19:23:45 CEST 2012


android | branch: master | Ludovic Fauvet <etix at videolan.org> | Tue Jul  3 19:10:30 2012 +0200| [74a650495799157b759af3cc0c49024694f3ba72] | committer: Ludovic Fauvet

Fix an IllegalStateException related to the onSaveInstanceState call

The error appears because we're attaching a new fragment in the onResume
and this method is sometimes called after onSaveInstanceState which
leads to a crash.
We can safely discard the state in this specific case because we don't
rely on the UI state but on the mMediaLibraryActive boolean to read the
actual state of the directory view.

> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=74a650495799157b759af3cc0c49024694f3ba72
---

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

diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 8d21e80..83f23cf 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -334,7 +334,7 @@ public class MainActivity extends SherlockFragmentActivity {
             mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
         /* Load directory view fragment */
         ft.attach(mDirectoryView);
-        ft.commit();
+        ft.commitAllowingStateLoss();
         mMediaLibraryActive = false;
     }
 
@@ -348,7 +348,7 @@ public class MainActivity extends SherlockFragmentActivity {
             mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
         /* Remove the directory view from the tabs */
         ft.detach(mDirectoryView);
-        ft.commit();
+        ft.commitAllowingStateLoss();
         mMediaLibraryActive = true;
     }
 



More information about the Android mailing list