android 摄像头参数,android – Intent不设置摄像头参数

不幸的是,将相机与Intent一起使用时,您可以设置的唯一额外参数是

MediaStore.EXTRA_OUTPUT

例如

fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); // create a file to save the image

intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name

这允许您映射Camera应用程序将存储图像的位置.

相机面对额外的意图有时可以工作:

action.putExtra("android.intent.extras.CAMERA_FACING", 1);

查看android源文件,有一些“测试”方法在Util类文件中,但没有正式记录:

(使用率)

private static final String EXTRAS_CAMERA_FACING =

"android.intent.extras.CAMERA_FACING";

// This is for test only. Allow the camera to launch the specific camera.

public static int getCameraFacingIntentExtras(Activity currentActivity) {

int cameraId = -1;

int intentCameraId =

currentActivity.getIntent().getIntExtra(Util.EXTRAS_CAMERA_FACING, -1);

if (isFrontCameraIntent(intentCameraId)) {

// Check if the front camera exist

int frontCameraId = CameraHolder.instance().getFrontCameraId();

if (frontCameraId != -1) {

cameraId = frontCameraId;

}

} else if (isBackCameraIntent(intentCameraId)) {

// Check if the back camera exist

int backCameraId = CameraHolder.instance().getBackCameraId();

if (backCameraId != -1) {

cameraId = backCameraId;

}

}

return cameraId;

}

在photomodule中,使用以下方法:

(PhotoModule)

private int getPreferredCameraId(ComboPreferences preferences) {

int intentCameraId = Util.getCameraFacingIntentExtras(mActivity);

if (intentCameraId != -1) {

// Testing purpose. Launch a specific camera through the intent

// extras.

return intentCameraId;

} else {

return CameraSettings.readPreferredCameraId(preferences);

}

}

当相机应用程序初始化照片模式时,它会调用此方法来检查要使用的相机:

mCameraId = getPreferredCameraId(mPreferences);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值