Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI.toString());
intent.putExtra("android.intent.extras.CAMERA_FACING", 0);
// ******** code for crop image
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 0);
intent.putExtra("aspectY", 0);
intent.putExtra("outputX", 200);
intent.putExtra("outputY", 150);
try {
intent.putExtra("return-data", true);
startActivityForResult(intent, PICK_FROM_CAMERA);
} catch (ActivityNotFoundException e) {
// Do nothing for now
}
我在Open Camera中使用了以下代码:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PICK_FROM_CAMERA) {
try {
Bundle extras = data.getExtras();
if (extras != null) {
photo = extras.getParcelable("data");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
此代码返回数据的位图,请告诉我如何设置相机总是向后,而不是总是前面,当我打开相机,请建议我的解决方案。
发布于 2016-04-20 19:39:04
您不能使用ACTION_IMAGE_CAPTURE
强制使用特定的相机。没有要求任何相机应用程序支持您在该Intent
上打包的许多未记录的额外内容。
如果您需要这种程度的控制,请直接使用camera API(例如,android.hardware.Camera
)并编写您自己的camera代码。
https://stackoverflow.com/questions/36742526
复制相似问题