2011-07-14 8 views
10

Bunu yapmak örneği okudum:bir URI java.io.FileNotFoundException sağlayan bit eşlem almak için: Hiçbir içerik sağlayıcı: /sdcard/Hello/1310610722879.jpg

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); 
    } 
} 

Ama java olsun .io.FileNotFoundException: hiçbir içerik sağlayıcı: /sdcard/Hello/1310610722879.jpg

Kodum burada:

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(); 
} 

herhangi bir fikir nasıl çalışması için? Etrafa haberci

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

cevap

22

Tamam, u bunu yapmak zorunda:

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

yapabilirsiniz

Tamam ben u bunu yapmak zorunda, etrafında haberci api dökümantasyonunda manuel olarak eklenmesi gereken MIME tipinin, RFC 2396 uyumlu eklemekten daha fazlasını eklemesi çok iyi olurdu:/ – amIT

+0

d Config.getPhotoPath() yönteminde, kodunuzda imageUri belirtmediyseniz, görüntüyü hala nasıl alabiliyorsunuz? – akshay7692

6

Yoksa

File file = new file(Config.getPhotoPath(this)); 
Uri uri1 = Uri.fromFile(file); 
İlgili konular