如何获得所捕获的图像的URL?如何获得、图像、URL

2023-09-07 01:01:46 作者:精神恍惚

我发起一个活动来捕获照相机的图片:

I launch an activity to capture a picture from camera:

Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE, null);
i.putExtra("return-data", true);
startActivityForResult(i, PICK_FROM_CAMERA);

你能告诉我怎么去捕捉画面的URI?

Can you please tell me how to get the URI of the capture picture ?

推荐答案

要得到的是刚刚从相机,你会做的图像以下

To get the image that was just taken from the camera you would do the following

// Call to take the picture
startActivityForResult(new Intent("android.media.action.IMAGE_CAPTURE"), PICK_FROM_CAMERA);

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
    if (requestCode == PICK_FROM_CAMERA)
    {
    	Uri uri = data.getData();
    		// set the imageview image via uri 
    		_previewImage.setImageURI(uri);
    }
}