3

I'm currently writing a application that needs to capture some images. I start the camera application using a intent like this:

if (v.equals(btnCap)) {
        Intent cameraIntent = new Intent(
                android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
        startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
    }

The problem is: When i tilt my device, the buttons on the camera still change their orientation and the picture I receive is not in portrait.

Does anyone know how to capture a image in portrait mode, even if the device is tilted?

Thanks in advance, Adrian

gary
  • 4,227
  • 3
  • 31
  • 58
awaelchli
  • 796
  • 7
  • 23

2 Answers2

1

You best option is to create your own camera app (http://developer.android.com/guide/topics/media/camera.html#custom-camera).

And then, in your AndroidManifest.xml, add the android:screenOrientation="portrait" option on the declaration of your activity.

It's better to build your own camera activity, because you can have issues for getting the pictures depending on the device model. I once had an issue with Samsung devices (see Android Samsung: Camera app won't return intent.getData())

Community
  • 1
  • 1
ndeverge
  • 21,378
  • 4
  • 56
  • 85
  • Thanks for the tip. I thought about building my own camera app, but I'm new to this and thought it would be better to start with some easier things :) – awaelchli Jan 21 '12 at 15:51
  • I started building my own camera in a new activity. Unfortunately I got in trouble loading/saving the bitmap. I don't know where to save or load the pictures. I used the method recommended in the developer guide you posted before. – awaelchli Jan 22 '12 at 14:40
1

use setDisplayOrientation (int degrees) it will make the job

if you are using you own camera you can use it like this

camera.setDisplayOrientation(90);

http://code.google.com/p/android/issues/detail?id=1193#c42

confucius
  • 13,127
  • 10
  • 47
  • 66