Mattia
Mattia

Reputation: 1117

Issue taking photo

I have to implement a function that allow the user to take a photo, I need to force the screen orientation to portrait.

More android devices, in particular tablets, are equipped of a rear camera that is mounted on the top of the case (portrait mode), others devices instead are mouted on the side of the tablet (landscape mode).

For example:

I need all the photos taken in portrait mode, the code below is the one I implemented but not work.

Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (cameraIntent.resolveActivity(getPackageManager()) != null) {
        cameraIntent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 
        File storageDir = new File(Environment.getExternalStorageDirectory() + PDF_FOLDER_C);
        cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));                                                                  
        startActivityForResult(cameraIntent, idRow);
    }

Upvotes: 0

Views: 51

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006539

I need all the photos taken in portrait mode

There is nothing with ACTION_IMAGE_CAPTURE for you to force a particular orientation, for the hundreds (if not thousands) of camera apps that might be started with ACTION_IMAGE_CAPTURE.

You are welcome to experiment with the native camera APIs (android.hardware.Camera, android.hardware.camera2.*) to see if you can get something like what you want. Bear in mind that the user is welcome to hold their device in whatever orientation that they want.

Upvotes: 1

Related Questions