【问题标题】:How to set the camera orientation in Android?如何在Android中设置相机方向?
【发布时间】:2014-11-30 21:28:52
【问题描述】:

我正在开发从相机拍照的 Android 应用程序。我只想将相机方向设置为纵向。下面给出了我的代码,我从那里向OnActivityResult发送请求:

 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);  
            ContentValues values = new ContentValues(3);  
            values.put(MediaStore.Images.Media.DISPLAY_NAME, "testing");  
            values.put(MediaStore.Images.Media.DESCRIPTION, "this is description");  
            values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");  
            imageFilePath = UserInfoActivity.this.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);  
 startActivityForResult(intent, 0); 

【问题讨论】:

    标签: android camera orientation android-camera-intent


    【解决方案1】:

    在您的代码中添加这些行

    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
        intent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION,ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);   
        startActivityForResult(intent,CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); 
    

    在您的 Manifest.XML 中添加这些行

    <activity
         android:name="ActivityName"
         android:screenOrientation="portrait"
         android:configChanges="orientation" >
         </activity>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-07
      • 1970-01-01
      • 1970-01-01
      • 2013-12-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多