I am developing an Android application that uses a camera preview in the background. It works great on different devices.
But when testing on the Nexus 5X, the camera preview is upside down. I use this permission in the manifest
<uses-permission android:name="android.permission.CAMERA" />
My camera code is as follows
public void startCamera(int myTexture)
{
surface = new SurfaceTexture(myTexture);
try {
camera = Camera.open();
} catch (Exception e) {
Log.e("MainActivity", "failed to open Camera");
e.printStackTrace();
}
try
{
camera1.setPreviewTexture(surface);
camera1.startPreview();
}
catch (IOException ioe)
{
Log.w("MainActivity","Camera launch failed");
}
}
Run codeTest Camera .setDisplayOrientation (180); But it didn’t work out. Please, help!
source
share