[英]Camera intent for ACTION_IMAGE_CAPTURE does not appear on Samsung Galaxy Nexus(4.0.2)
I use following code take a Picture from camera and to obtain picture's path. 我使用以下代码从相机拍摄照片并获取照片的路径。
...
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_IMAGE_CAPTURE); // image capture
...
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.d(TAG, "onActivityResult:" + resultCode + " request:" + requestCode);
switch (requestCode) {
case CAMERA_IMAGE_CAPTURE:
Uri selectedImageUri = data.getData();
userImagePath = getPath(selectedImageUri);
break;
}
}
It works good on emulator and on different devices. 它在仿真器和不同设备上运行良好。 But on Samsung Galaxy Nexus(4.0.2) it does not launches Camera app.
但在三星Galaxy Nexus(4.0.2)上,它没有推出Camera应用程序。 But it returns RESULT_OK to onActivityResult and I see no exceptions in LogCat.
但是它将RESULT_OK返回给onActivityResult,我在LogCat中看不到任何异常。 Please give me and advice how to solve this issue.
请给我并建议如何解决这个问题。 Thanks in advance!
提前致谢!
You are missing EXTRA_OUTPUT
, which may impact matters. 您缺少
EXTRA_OUTPUT
,这可能会影响问题。 My Galaxy Nexus can run this sample project successfully, which uses the following code to request the picture: 我的Galaxy Nexus可以成功运行此示例项目 ,它使用以下代码来请求图片:
Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
output = new File(dir, "CameraContentDemo.jpeg");
i.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(output));
startActivityForResult(i, CONTENT_REQUEST);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.