3

I want to open the native camera app through intent in my application. I have used the following lines of code.

Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
startActivityForResult(takePictureIntent, actionCode);

Now, I want to lock the orientation of camera in portrait when it is opened. I just added the below line to the above piece of code.

takePictureIntent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION,
                    ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

But, it is not working. The Camera opened is not locked to portrait. It is moving in all the orientation. Please help me to solve this issue.

Thanks in Advance !!!

Avijit
  • 3,834
  • 4
  • 33
  • 45

1 Answers1

-2

To force portrait orientation:

place android:screenOrientation="portrait" in your AndroidManifest.xml

Rama
  • 1,156
  • 1
  • 7
  • 13