Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lock your camera view to landscape mode in android [duplicate]

I want to lock my camera view to "Landscape" mode.When I click on the simple button in my app, that time device's camera will open and and that camera should be locked to "Landscape mode". Can anyone know the solution of this problem?

I am using this code inside "CaptureImageActivity.java" activity. So after execution of this activity my system's camera will open.

btn1.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            Intent i=new Intent(android.provider.MediaStore. ACTION_IMAGE_CAPTURE);
            i.putExtra(android.provider.MediaStore.EXTRA_SCREEN_ORIENTATION,ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);


            startActivityForResult(i,1000);

        }
    });

And I want to lock that camera view to "LandScape Mode". And as per solution

<activity android:name=".CaptureImageActivity"
    android:screenOrientation="landscape"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

Only "CaptureImageActivity" activity is locked to "LandScape Mode".

like image 640
Kush Patel Avatar asked Nov 13 '22 21:11

Kush Patel


1 Answers

see this link to lock your camera orientation,use setDisplayOrientation (int degrees)

documentation can be found on following link : http://developer.android.com/reference/android/hardware/Camera.html#setDisplayOrientation%28int%29

for more details see this answer :

How to set Android camera orientation properly?

like image 74
Shruti Avatar answered Nov 15 '22 12:11

Shruti