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,189
  • 2
  • 30
  • 58
aeduG
  • 601
  • 7
  • 22

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,158
  • 4
  • 55
  • 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 :) – aeduG 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. – aeduG 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
  • 12,867
  • 10
  • 46
  • 66