2011-10-01 23 views
5

, bir dosya var: Bu benim sınıfta doğrudan bildirilmişBitmapFactory.decodeFile(); Benim uygulamada

private File TEMP_PHOTO_FILE = new File(Environment.getExternalStorageDirectory(), "temp_photo.jpg"); 

ve orada tüm yöntemlere görülebilir

Bunu kullanmak istiyorum.

Bitmap thePhoto = BitmapFactory.decodeFile(Uri.fromFile(TEMP_PHOTO_FILE).toString()); 

Bu neden çalışmıyor: "///mnt/sdcard/temp_photo.jpg dosyası:"

Uri.fromFile (TEMP_PHOTO_FILE) .ToString() dize oluşturur? Bir dosya ile uğraştığımız için, bir URI'yi girdi olarak kabul eden bir decodeFile() yöntemi kullanılmalıdır. Buna izin vermemek, tutarsızlıktan dolayı çok sinir bozucu.

cevap

2

"file: //" çalışmıyor. Bunu deneyin:

Bitmap thePhoto = BitmapFactory.decodeFile(TEMP_PHOTO_FILE.getAbsolutePath().toString());