1

I have a fragment that contains a VideoView and I want it to keep playing when orientation changes.

I've been searching for similar cases but I don't know the best way to proceed.

If I "setRetainInstance(true)" in the fragment's onCreate method it seems not to be enough

Can anybody give me a little help? Thanks

uhuru
  • 11
  • 2

1 Answers1

0

You can try overriding onConfigurationChanged in the fragment, leaving it blank:

@Override
public void onConfigurationChanged(Configuration newConfig){
    super.onConfigurationChanged(newConfig);        

}

Works for a normal activity so should work fine in a fragment. You might need to override it in the parent activity as well.

Edit:

Forgot to say, you need to add the following tag to the activity's manifest.

android:configChanges="orientation" 
David Scott
  • 1,666
  • 12
  • 22
  • I've tried to override onConfigurationChanged in both the fragment and in its parent activity and they're not running (I put a Toast in both methods and it's never shown). Is there any way to do it without override onConfigurationChanges???? Thanks again – uhuru Apr 24 '12 at 11:33
  • Edited my comment with the tag you need to add to the manifest to get onConfigurationChanged to be called. – David Scott Apr 24 '12 at 12:06