How to Prevent Screen Orientation from Changing by Returning from Camera Intent (SGS3)

In my application, I call the second action using ImgButton, which calls the camera's onClick () intent. After I take a photo, in my activity, I show an AlertDialog window where the user can choose another photo or not. In my manifest, I have locked the orientation of the 2nd activity to portrait, because if I rotate the device, the AlertBox disappears:

<activity android:name="SecondActivity"
            android:screenOrientation="portrait"></activity>

      

In my Mannifest, I also added:

android:configChanges="orientation|keyboardHidden"

      

and for full screen mode

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

      

If I take a photo and close the camera intent in portrait mode (without rotating the device), there is a problem with two different devices:

HTC Desire: Everything works fine, I save the application states and restore them if I return from the camera to my activity: D

Galaxy S3 *: camera on sgs3 seems to be running in landscape mode by default? so if u go back to my activity, the displayed content of my activity will be for eye blinking in landscape mode and back to portrait mode. BUT THE DIALOG SELECT is displayed before the orientation changes, so the AlertDialog disappears before unwanted rotation (so I only see the AlertBox for 0.1 seconds in landscape mode before it disappears and the rotation returns to portrait mode). ..

If I end up intent on the camera from landscape mode it doesn't matter what device the problem is the same as on sgs3 *.

How can I prevent this screen rotation after I return to my activity from the camera? Can I just show the AlertBox after changing this unwanted orientation? If so, how can I do this? Or other workarounds?

Thanks and sorry for my bad english ... xD

+3


source to share


1 answer


I solved my problem on my own: I just put

AlertDialog [...] show () ;.

into action onResume()

, so if I go back from the camera to my activity, the AlertDialog rotates with the screen instead of disappearing.

This raises the error WindowManager



"[package name] leaked window ..."

but in the end it worked the way I want and the app doesn't crash ...

Not sure if this is the best and correct solution, but it works.

0


source







All Articles