I am trying to use the camera inside my application and I had a problem with the correct handling of configuration changes. I know the correct way to handle configuration changes in a typical Activity (onSaveInstanceState, etc.), but this is not the case here.
Think of my activity as a full-screen camera view with the button of the folded shutter and the frame that will be used to crop the image
What I'm trying to achieve (HTC Sense camera stock preview): http://youtu.be/uzfUJUNHY68
That is: the preview of the camera, which is located on the TextureView , should not be recreated during rotation, but the activity should be orientation-oriented in order to position the elements.
I am sure that I do not want the Activity recreated on rotation. So I tried the android:configChanges . The problem is that onSurfaceTextureSizeChanged() is still being called and the camera preview rotates and the whole experience is not smooth (the preview pauses for a while and gets “recreated” or something else).
I tried to block my activity to the landscape using android:screenOrientation="landscape" , but this onConfigurationChanged() method is not called, and I don’t know how to position other views, like in the video above. I think I could listen to some accelerator events , but I'm sure there is a better way. There is?
source share