Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For lower API levels you could use:</p> <pre><code>private void setCameraDisplayOrientationAPI8(){ //Sets the camera right Orientation. //Special void for API 8 build. //This void should be called before calling camera.setParameters(cameraParameters). if (activeActivity.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { camera.setDisplayOrientation(90); } if (activeActivity.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { camera.setDisplayOrientation(180); } } </code></pre> <p>and just call <code>setCameraDisplayOrientationAPI8();</code> on your <code>surfaceChanged</code> func.</p> <p>plus:</p> <pre><code>private void setCameraDisplayOrientation() { //Sets the camera right Orientation. //IMPORTANT!! This code is available only for API Level 9 build or greater. if (mApiLvl&lt;9){ Log.d(TAG, "setCameraDisplayOrientation ERROR: This code is available only for API Level 9 build or greater."); return; } android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); android.hardware.Camera.getCameraInfo(cameraIndex, info); int rotation = activeActivity.getWindowManager().getDefaultDisplay() .getRotation(); int degrees = 0; switch (rotation) { case Surface.ROTATION_0: degrees = 0; break; case Surface.ROTATION_90: degrees = 90; break; case Surface.ROTATION_180: degrees = 180; break; case Surface.ROTATION_270: degrees = 270; break; } int result; if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { result = (info.orientation + degrees) % 360; result = (360 - result) % 360; // compensate the mirror } else { // back-facing result = (info.orientation - degrees + 360) % 360; } camera.setDisplayOrientation(result); } </code></pre> <p>hope this helps.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload