I have an activity which contains fragments and every fragment performs different action.

Now after some time, I want to change the activity orientation to Potrait and continue what ever is playing in the fragments.

final Handler handler2 = new Handler();
    handler2.postDelayed(new Runnable() {

        public void run() {
              setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 
        }

    }, 10000);

This is how I change the orientation after 10 seconds. I have also added the config changes in the manifest file.

This works if I am playing just images in the fragment but If I play vidoes, then the videos appear twice on screen rotation . If I display google maps, then my app crashes.

Do I need to save the instance when I rotate the screen? Any tips would be really helpful.

Related posts

Recent Viewed