Android三星:相机应用程序不会返回intent.getData()

Jac*_*Sam 8 android

我正在开发一个应用程序,其中从本机相机应用程序拍摄的图像.将向用户显示.我做的代码是:

/* Intent */
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
startActivityForResult(intent, TAKE_PICTURE);

/* Result */
onActivityResult(int requestCode, int resultCode,
        Intent returnIntent) {
    if(requestCode == TAKE_PICTURE) {
        //picture from Camera
        if (resultCode == Activity.RESULT_OK) {
            if(returnIntent != null) {
                try {
                    // Get the file path where the image is stored.
                    // This runs fine on all devices, except Samsung ones.
                    Uri selectedImage = returnIntent.getData();

                    if(selectedImage == null) {
                        if(returnIntent.getExtras() != null &&
                            returnIntent.getExtras().get(AppConstants.DATA) != null) {

                            // But, I get the image Bitmap here. Means the image is stored in disk.
                            Bitmap bmp = (Bitmap) returnIntent.getExtras().get(AppConstants.DATA);
                        }
                    }
                } catch (Exception e) {
                    //
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这里的问题是,上面的代码在我试过的所有设备(HTC,SE)上工作正常,但它在三星的某些方面失败了."Uri selectedImage = returnIntent.getData();" 永远不会退货.由于我的整个应用程序是基于文件路径存储的逻辑构建的,我无法继续.有没有解决方案的人.

typ*_*.pl 11

请参阅指定用于代码的图片的文件名,以指定Intent的EXTRA_OUTPUT参数,该参数允许您指定图片的文件名.调用活动结果时记住文件名,如果intent.getData为NULL,则使用该文件名

如果您阅读该错误报告中的其他评论,您将会发现Android上的图片有多少问题.