通过意向使用手机摄像头 - 活动永远不会返回? [英] Using phone camera via Intent - activity never returns?

查看:98
本文介绍了通过意向使用手机摄像头 - 活动永远不会返回?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的Andr​​oid应用程序手机的摄像头拍摄照片。我使用意图使用内置的摄像头应用程序,我用下面的code:

I'm using the phone's camera in an Android app to take a photo. I'm using Intents to use the built-in camera application and I'm using the following code:

Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(FILEPATH)));
startActivityForResult(intent, ACTIVITY_NATIVE_CAMERA_AQUIRE);

它工作正常,相机长大的。我可以把照片和电话presents我有三个选项:取消,重摄,确定。前两个工作,pressing取消返回用户应用程序,但pressing确定和的没有的发生。显然onActivityResult没有被调用,并且相机只是停留在屏幕上。在调试器或者什么也没有。

It works fine and the camera is brought up. I can take a photo and the phone presents me with three options: Cancel, Retake, OK. The first two work, pressing cancel returns the user to the app, but pressing OK and nothing happens. Apparently onActivityResult isn't being called, and the camera just stays on the screen. Nothing in the debugger either.

这是一个的Nexus One采用Android 2.2.1运行的应用程序。在运行Android 2.0模拟器同样的问题

Running the app on a Nexus One with Android 2.2.1. Same problem on the emulator running Android 2.0.

修改的:测试在HTC Desire采用HTC的Sense UI运行Android 2.2:完美的作品。没事就emalator也不是谷歌N1。

Edit: Tested on a HTC Desire running Android 2.2 with HTC's Sense UI: works perfectly. Nothing on the emalator nor Google N1.

EDIT2 的:如此看来,HTC Desire的图像aquiring活动的作品在这个意义上更好,它并返回,但它忽略了EXTRA_OUTPUT - 设置并返回在onActivityResult -call只是一个小图像。检查对DDMS控制台,而在手机钩住我看到手机存储图像的SD卡上的计算机,但路径不回传给我的应用程序。它开始看起来像有使用摄像头的意图,并取回一个合理的尺寸图像没有可靠的方法。坏,坏,坏的。

Edit2: It seems that the HTC Desire image aquiring activity works better in the sense that it does return, but it disregards the EXTRA_OUTPUT -setting and returns only a small image in the onActivityResult -call. Checking on the ddms console while the phone is hooked to the computer I see that the phone is storing the image on the SD card, but the path is not passed back to my application. It is starting to look like there is no reliable way to use the camera intent, and get back a reasonably-sized image. Bad, bad, bad.

推荐答案

在一些研究,测试和侥幸我设法解决这个问题。

After a bit of research, testing and sheer luck I managed to solve this issue.

如果该EXTRA_OUTPUT -option为意图包含文件的URI指向装置的内部存储器,则调用将失败。它是如何失败,取决于设备。 HTC Desire的工程确定在表面上,但无法返回完整的大图。谷歌N1,另一方面拒绝从相机的活动离开了。

If the EXTRA_OUTPUT -option for the Intent contains a file URI that points to the internal memory of the device, the call will fail. How it fails, depends on the device. The HTC Desire works ok on the surface, but fails to return the full-sized image. Google N1 on the other hand refuses to leave from the camera activity.

当我改变了文件URI指向存储卡,它的工作完美地为欲望和谷歌N1。

When I changed the file URI to point to the memory card, it worked perfectly for both the Desire and Google N1.

所以,总结起来:路径来存储全尺寸的图像必须指向SD卡

So summing it up: the path to store the full sized image MUST point to the SD card.

这篇关于通过意向使用手机摄像头 - 活动永远不会返回?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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