Android,调试MediaStore.ACTION\u图像\u捕获意图

Android,调试MediaStore.ACTION\u图像\u捕获意图,android,android-camera,image-capture,android-camera-intent,Android,Android Camera,Image Capture,Android Camera Intent,我正试图通过以下方式与MediaStore.ACTION\u IMAGE\u拍摄照片: String fileName = "testphoto.jpg"; ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, fileName); values.put(MediaStore.Images.Media.DESCRIP

我正试图通过以下方式与MediaStore.ACTION\u IMAGE\u拍摄照片:

        String fileName = "testphoto.jpg";
        ContentValues values = new ContentValues();
        values.put(MediaStore.Images.Media.TITLE, fileName);
        values.put(MediaStore.Images.Media.DESCRIPTION,
                "Image capture by camera");
        values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
        imageUri = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values);
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
        startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE)
                .putExtra(MediaStore.EXTRA_OUTPUT,
                        MediaStore.Images.Media.EXTERNAL_CONTENT_URI),
                R.id.capture_image_request);
处理活动结果:

        try {
            uploadedPicture = BitmapFactory.decodeStream(getContentResolver()
                                           .openInputStream(imageUri));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
在那之后,我试着展示刚刚拍摄的照片:

((ImageView) findViewById(R.id.profile_picture_thumbnail)).setImageBitmap(uploadedPicture);
这是行不通的。之后,我尝试从该Uri打开一个输入流:

final InputStream is = getContentResolver().openInputStream(uri);
Log.("mydebug tag", is.available());
is.available()返回0。为什么那个文件是空的

当我尝试调试时,我发现Uri类似于“content://media/external/images/media/68“他已经回来了。 之后,我硬编码:

    Uri uri = Uri.parse("content://media/external/images/media/68");

    Bitmap pic;
    try {
        pic = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));
        ((ImageView) findViewById(R.id.profile_picture_thumbnail)).setImageBitmap(pic);
    } catch (FileNotFoundException e) {
        Log.e(TAG, e.getMessage());
    }
这起作用了

所以我想知道为什么当我手动构造Uri时——它可以工作,但当我收到一个刚拍摄的照片的Uri时——它却不能工作?我有一种感觉,当我访问刚拍摄的照片的Uri时,它还没有存储在文件系统中,这就是为什么它的大小等于0并且不能加载到ImageView中。但过了一段时间(当我再次运行我的应用程序时,使用硬编码Uri)文件被存储并正常工作。有没有办法将该文件强制刷新到磁盘上