Properly handling rotation of camera (in TextureView)
android, android-camera
Solution
Android camera source.
Lock activity rotation. On method `onOrientationChanged` of `MyOrientationEventListener` you can rotate, change positions of views etc. I think it's a best way.
Problem
I try to use a Camera inside my app and I have a problem with proper handling of configuration changes. I know the proper way of handling configuration changes in a typical `Activity` (onSaveInstanceState etc...), but it's not the case here. Think of my Activity as a fullscreen camera preview with an overlay shutter button and a frame which will be used to crop the image What I'm trying to achieve (preview of a stock HTC Sense camera): http://youtu.be/uzfUJUNHY68 That is: the camera preview which is on `TextureView` should not be recreated on rotation, but the Activity should be orientation-aware, to position elements. I'm pretty sure I don't want the `Activity` to be recreated on rotation. So I tried the `android:configChanges` approach. The problem is that `onSurfaceTextureSizeChanged()` is still called and the camera preview is rotated and the whole experience is not smooth (the preview lags for a moment and gets "recreated" or something). I tried locking my Activity to landscape via `android:screenOrientation="landscape"`, but this way `onConfigurationChanged()` is not called and I don't know how to position other views like in the video above. I guess I could listen to some accelerator events, but I'm pretty sure there is a better way. Is there?