拍照后在onActivityResult中获取图像Uri?
我有这个代码:
startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE), CAMERA_IMAGE);
允许该用户拍照。现在我如何在 onActivityResult
中获取该照片的 Uri
?这是一个额外的Intent
吗?是通过Intent.getData()
吗?
I have this code:
startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE), CAMERA_IMAGE);
That allows that user to take a photo. Now how would I get the Uri
of that photo in onActivityResult
? Is it an Intent
extra? Is it through Intent.getData()
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
顺便说一句......在某些设备中存在一个与此意图相关的错误。查看此答案了解如何解决该问题。
By the way... there's a bug with that intent in some devices. Take a look at this answer to know how to workaround it.
不要只是启动意图,还要确保告诉意图您想要照片的位置。
然后,当您调用 onActivityResult() 方法时,如果成功,只需打开一个到 URI 的流,并且应该全部设置完毕。
Instead of just launching the intent, also make sure to tell the intent where you want the photo.
Then when you get your onActivityResult() method called, if it was a success just open a stream to the URI and it should all be set.