I am building an app that contains a video capture from a custom camera with a surface view. It works fine in portrait mode, but when I change to landscape mode the camera preview goes to a blank screen.
Here's the code I'm using:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
setContentView(R.layout.camera_activity);
camera1 = Camera.open(camId);
try {
camera1.setPreviewDisplay(surfaceHolder);
camera1.startPreview();
} catch (IOException e) {
e.printStackTrace();
}
}
In the ConfigurationChanged
function I'm not getting the camera1
Object.
How can I solve this?