图片已保存在目录中但无法预览

时间:2020-03-03 12:41:30

标签: android image file path bitmap

我的应用程序拍照并在gridview中显示,但是我的问题是当我去通知的目录中查看它时,它出现在目录中,但是图像不返回,

这是我的代码:

private File createImageFile() throws IOException {

    // Create an image file name
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmm").format(new Date());
    String imageFileName = "relatorio" + timeStamp + "_";

    String path = Environment.getExternalStorageDirectory().toString() + "/VIEW REPORT/IMAGENS";
    sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
            Uri.parse("file://" + Environment.getExternalStorageDirectory())));


    File dir = new File(path);
    if(!dir.exists())
        dir.mkdirs();


    File file = new File(dir, imageFileName);

    if( mCurrentPhotoPath != null ) {

        // write the document content
        try {
            OutputStream out = new FileOutputStream(file);
            Toast.makeText(this, "PICTURE SAVE", Toast.LENGTH_LONG).show();

        }

        catch (IOException e) {
            e.printStackTrace();
            Toast.makeText(this, "TRY AGAIN: ", Toast.LENGTH_LONG).show();
        }


    }

    File image = File.createTempFile(
            imageFileName,  /* prefix */
            ".jpg",         /* suffix */
            dir      /* directory */
    );

这是我的设备文件浏览器,有人可以帮我吗?

请注意,其大小为0B

enter image description here

0 个答案:

没有答案