Android的图像不会保存在使用Nexus S的原生相机应用 [英] Android Image doesn't save using native camera app on Nexus S
问题描述
因此,这是一种奇怪的,因为出了三个设备我测试上,我只得到这个问题的谷歌Nexus S采用4.0.3。我开始原生相机应用拍照,我不在乎保存图像,所以我不指定,希望它会被保存到默认位置,但没有位置被保存在所有!
是否在Galaxy S 2和三星扶摇直上做工精细(都与2.3.something)。
code我使用来启动应用程序
意图camIntent =新意图(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(camIntent,TAKE_PHOTO);
返回true;
我保持它很简单,这就是为什么我很困惑!有谁知道具体到歌Nexus S的摄像头的问题?
编辑:这似乎是可能的歌Nexus S的摄像头应用程序可以节省一些的onActivityResult的文件,因为我启动本机摄像头的应用程序,不保存在返回的形象,这不是T保存。有谁知道这这是真的吗?看到这种行为?
编辑:没有人见过这个?我很难相信我碰到这个第一人......
编辑:好吧,它的工作多一些好后,我尝试添加一个URI到意图EXTRA_OUTPUT像这样:
camIntent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.parse(FOLDERPATH +的String.format(%D.JPG,返回System.currentTimeMillis())));
而现在我看到这里所描述的行为:的Android ACTION_IMAGE_CAPTURE意图相机进行应用程序没有做任何事情,当我点击确定,并创建文件事先也不管用,因为我想是这样的:
文件f =新的文件(FOLDERPATH,文件名);
f.createNewFile();
camIntent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.parse(FOLDERPATH +文件名));
好吧,理解了它。奇怪的是,我不知道为什么,但改变这一行:
camIntent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.parse(FOLDERPATH +文件名));
到
camIntent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(文件));
固定它。不知道是不是我应该明白为什么......但不管,它的工作原理。我也尝试了十亿其他的事情...
不指定EXTRA_OUTPUT在所有 - >相机会像一切都很好...除了它不会保存图像ANYWHERE
过得去intent.getExtras()采取的位图获取(数据) - >回做一个位图,但它并不像很多错误报告广泛记录了全尺寸图片
使用上述方法Uri.parse- >使原生相机应用的勾号按钮点击时没有做任何事情。
希望这可以帮助别人。
So this is kind of weird because out of the three devices I'm testing on, I only get this issue on the Google Nexus S with 4.0.3. I'm starting the native camera app to take a picture, and I don't care where the image is saved to, so I don't specify, hoping that it will get saved to the default location, but no location is saved at all!
Does work fine on the Galaxy S 2 and Samsung Skyrocket (both with 2.3.something).
Code I'm using to start the app
Intent camIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(camIntent, TAKE_PHOTO);
return true;
I'm keeping it really simple, that's why I'm confused! Does anyone know of any issues specific to the Nexus S's camera?
EDIT: It would seem that maybe the Nexus S's camera app saves the file in some onActivityResult, and since I start up the native camera app and don't save the image upon return, it doesn't save it. Does anyone know this this to be true? Seen this behavior?
EDIT: No one has seen this? I find it hard to believe I'm the first person to run into this...
EDIT: Alright, well after working on it some more, I tried adding a URI into the EXTRA_OUTPUT of the intent like so:
camIntent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.parse(folderPath + String.format("%d.jpg", System.currentTimeMillis())));
And now I see the behavior described here: Android ACTION_IMAGE_CAPTURE Intent where the camera app doesn't do anything when I hit ok, and creating the file beforehand doesn't work either, as I tried like this:
File f = new File(folderPath, filename);
f.createNewFile();
camIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.parse(folderPath + filename));
Alright, figured it out. Oddly, and I have NO idea why, but changing this line:
camIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.parse(folderPath + filename));
to
camIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
fixed it. Don't know if I should understand why... but whatever, it works. I did try a billion other things...
not specifying an EXTRA_OUTPUT at all -> camera would act like everything was good... except it wouldn't save the image ANYWHERE
getting the bitmap taken by intent.getExtras().get("data") -> did return a bitmap, but it was not the full size image as documented extensively in many bug reports
using the above Uri.parse method -> causes the native camera app checkmark button to not do anything when clicked
Hope this helps someone..
这篇关于Android的图像不会保存在使用Nexus S的原生相机应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!