Android摄像头:onActivityResult()原意为空,如果它有群众演员 [英] android camera: onActivityResult() intent is null if it had extras

查看:118
本文介绍了Android摄像头:onActivityResult()原意为空,如果它有群众演员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在堆栈溢出中的所有相关问题搜索了很多,什么也没找到后,请尝试帮助我。

After searching a lot in all the related issues at Stack Overflow and finding nothing, please try to help me.

我创建了一个意图拍摄一张照片。然后,我看到不同的行为,在 onActivityResult():如果我不把任何额外的意图(对小图片)在onActivityResult的意图是好的,但是当我把群众演员的意图写的PIC到一个文件中,在onActivityResult的目的是

I created an intent for capture a picture. Then I saw different behavior at onActivityResult(): if I don't put any extra in the Intent (for small pics) the Intent in onActivityResult is ok, but when I put extras in the intent for writing the pic to a file, the intent in onActivityResult is null!

意图创建:

Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
// without the following line the intent is ok
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
startActivityForResult(takePictureIntent, actionCode);

为什么是空的,我怎么能解决呢?

Why is it null, and how can I solve it?

推荐答案

它发生同样的给我,如果你所提供的 MediaStore.EXTRA_OUTPUT ,那么其意图是空,但你将有你的照片提供的文件中( Uri.fromFile(F))。

It happens the same to me, if you are providing MediaStore.EXTRA_OUTPUT, then the intent is null, but you will have the photo in the file you provided (Uri.fromFile(f)).

如果您不指定 MediaStore.EXTRA_OUTPUT ,那么你将有一个包含从哪里相机保存的照片所在的文件中的URI的意图。

If you don't specify MediaStore.EXTRA_OUTPUT then you will have an intent which contains the uri from the file where the camera has saved the photo.

不知道这是否是一个错误,但它工作的方式。

Don't know if it as a bug, but it works that way.

希望它可以帮助

这篇关于Android摄像头:onActivityResult()原意为空,如果它有群众演员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆