开发者

How to get bitmap providing a URI, java.io.FileNotFoundException: No content provider: /sdcard/Hello/1310610722879.jpg

I've read the example to do this:

 protected void onActivityResult(int requestCode, int resultCode, Intent data)
 {
     super.onActivityResult(requestCode, resultCode, data);
     if (resultCode == RESULT_OK)
     {
         Uri imageUri = data.getData();
         Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(),              imageUri);
     }
 }

But i get java.io.FileNotFoundException: No content provider: /sdcard/Hello/1310610722879.jpg

My code is here:

Uri uri1 = Uri.parse(Config.getPhotoPath(this));                
try {
    Bitmap bitmap = 开发者_如何学编程MediaStore.Images.Media.getBitmap(this.getContentResolver(), uri1);
    attachButton.setImageBitmap(bitmap);
} catch (Exception e) {
    // TODO: handle exception
    e.printStackTrace();
}

Any ideas how to make it work?

Ok I messed around, u have to do this:

Uri uri1 = Uri.parse("file://" + Config.getPhotoPath(this));


Ok I messed around, u have to do this:

Uri uri1 = Uri.parse("file://" + Config.getPhotoPath(this));


Or you can do

File file = new file(Config.getPhotoPath(this));
Uri uri1 = Uri.fromFile(file);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜