Question

My app does the following:

  1. I take a picture
  2. The picture is displayed in a DialogFragment

If I take the picture in landscape mode, I want the orientation of the DialogFragment which is showing my image to be locked to landscape mode. If I take the image in portrait mode, I would like the orientation of the DialogFragment be locked to portrait mode.

Is that possible?

Was it helpful?

Solution

Check the width and height of your image, that should be enough to tell you wether it was taken in portrait or landscape mode. Set your orientation with

getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

or

getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

And if you want to re-enable your auto-rotate functions at a later time just use

getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top