Android 从相机获取全尺寸图像在Galaxy S上不起作用

Android 从相机获取全尺寸图像在Galaxy S上不起作用,android,camera,Android,Camera,我在从三星Galaxy S上的内置照相机应用程序中捕获图像时遇到问题 我的应用程序上有一个按钮,按下该按钮可启动相机: ContentValues values = new ContentValues(); values.put(Images.Media.MIME_TYPE, "image/jpeg"); mPicUri = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values); intent = new Intent

我在从三星Galaxy S上的内置照相机应用程序中捕获图像时遇到问题

我的应用程序上有一个按钮,按下该按钮可启动相机:

ContentValues values = new ContentValues();
values.put(Images.Media.MIME_TYPE, "image/jpeg");

mPicUri = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values);

intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, mPicUri.getPath());
startActivityForResult(intent, REQ_CODE_TAKE_PIC);
从我在interwebz上读到的内容来看,我可以使用我传递给intent的URI获得刚刚拍摄的全尺寸照片。我的onActivityResult上有这样一个结果:

Uri selectedImage = mPicUri;
String[] filePathColumn = {MediaStore.Images.Media.DATA};

Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
cursor.moveToFirst();

int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filePath = cursor.getString(columnIndex);
cursor.close();
然后使用变量filePath,在ImageView中设置图像。我没有得到任何图像,当我浏览代码时,我发现
BitmapFactory.decodeFile()
正在返回
null

Bitmap chosenPic = BitmapFactory.decodeFile(filePath);
所以我尝试了更多的调试。我发现mPicUri返回一个看似有效的URI,例如:
content://media/external/images/media/90
。拍摄完照片并用户选择保存照片后,光标将解析为以下文件路径:
/sdcard/DCIM/Camera/1285601413961.jpg
。虽然没有位图被解码,但是当我浏览画廊时,我刚刚拍的照片就在那里。所以我试着看一下那张照片的URI,我得到的是:

URI is:           content://media/external/images/media/91
File path is:     /sdcard/DCIM/Camera/2010-09-27 23.30.30.jpg
因此,看起来我从mPicUri得到的值不是将要使用的最终URI

我在这里漏了一步吗?我真正想做的就是检索刚刚拍摄的照片的文件

提前感谢,,
Zarah。

您是否在拍照前和拍照后都尝试指定文件

public static File getTempFile() {
    //it will return /sdcard/image.jpg
    final File path = new File(Environment.getExternalStorageDirectory(), "MyApp");
    if (!path.exists()) {
        path.mkdir();
    }
    return new File(path, "image.jpg");
}

我正在使用此函数获取和设置文件路径。

是否找到解决此问题的方法?嗨@OhDannyBoy!对不起,我离开StackOverflow有一段时间了。我想我想出了一个办法,那就是在家检查我的代码。会让你知道的!此资源具有用于检索图像的代码。但是非常感谢你的帮助!你们的问题有什么答案吗?我在galaxy mini选项卡上也遇到了同样的问题,若有任何想法,请帮助我。