有没有办法从我自己的应用程序中打开默认的相机应用程序并使用它来获取图片/视频?我一直在尝试查找它,但我只找到了关于自己克隆相机应用程序的说明(通常带有非常糟糕的说明)。我知道这可以用 iPhone 完成,如果 Android 无法做到这一点,我会感到惊讶。
James
问问题
1024 次
3 回答
3
要让相机拍照然后获取刚刚拍摄的图像,请使用以下命令
// Call to take the picture using the default camera
startActivityForResult(new Intent("android.media.action.IMAGE_CAPTURE"), PICK_FROM_CAMERA);
// After the camera intent finished returns the uri of the image taken
@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);
}
}
于 2009-11-02T14:19:00.097 回答
2
这是他启动相机意图并获取图像的一些示例代码:
http://www.androidph.com/2008/11/camera-capture.html
(警告,它大约有一年的历史,所以需要一点更新)。
于 2009-11-01T16:55:43.780 回答
2
是的,你可以。这是 Android 意图背后的想法之一。
看看这里。
于 2009-11-01T18:09:59.467 回答