Force portrait mode in camera

前端 未结 5 715
眼角桃花
眼角桃花 2020-12-19 09:00

I am invoking a camera using an intent and clicking a picture. Presently I am on emulator and would like to force camera to click the pictures in portrait mode(need to captu

相关标签:
5条回答
  • 2020-12-19 09:50

    This shoudl work:

     Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
     i.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 
     i.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
     startActivityForResult(i, CAMERA_CODE); 
    
    0 讨论(0)
  • 2020-12-19 09:55

    None of the solutions work.There is nothing wrong with the layouts either.I got it to work by running on a higher version(API10 to API15). Weird!!

    0 讨论(0)
  • 2020-12-19 09:56

    You only need to set Id for each of your views. You don't need to force portrait mode in camera. Doing this, prevent the activity to recreate views and losing data

    0 讨论(0)
  • 2020-12-19 09:57

    Write in your manifest.xml where you have defined your this activity.

    <activity android:name="your_activity name" android:screenOrientation="portrait" />
    

    This should work. I suggest you to check in real device.

    use this code for your image capturing class where your preview is starting.

    0 讨论(0)
  • 2020-12-19 10:01

    I think this is a known problem, see Camera|SetDisplayOrientation

    0 讨论(0)
提交回复
热议问题