Android: retaining camera preview on orientation change while other views can rotate
I'm trying to build a custom camera app. I have a class which extends SurfaceView for the camera preview. When the device changes orientation, this surface is destroyed and recreated, leading to a noticeable "glitch" which diminishes user experience. What I'd like to do is to prevent this camera preview from having to be recreated on orientation change. In addition, I'd like to have some buttons overlaying this preview (e.g. flash, choice of front/back camera etc.) which WOULD rotate on orientation change. This is similar to what the stock camera app does: Stock camera in landscape mode. Stock