2011-09-12 38 views
1

一個簡單的測試應用程序:一個ImageView的兩個按鈕和一個功能ERROR/MemoryFile:MemoryFile.finalize()調用時ashmem仍然開放

public void onClick(View v) 
{ 
    String photoId = (v.getId() == R.id.button1)?"2472":"2434"; 
    Uri uri = Uri.withAppendedPath(ContactsContract.Data.CONTENT_URI, photoId); 
    ImageView img = (ImageView)findViewById(R.id.imageView1); 
    img.setImageURI(uri); 
} 

有好幾次我點擊按鈕 - 照片被正確加載。但LogCat說(幾行):錯誤/ MemoryFile:MemoryFile.finalize()在ashmem仍然打開時調用。
嗯...
問題是否存在?如何使用setImageURI?

回答

2

現在我使用以下命令:

final java.io.InputStream input = context.getContentResolver().openInputStream(uri); 
final Bitmap bm = BitmapFactory.decodeStream(input); 
input.close(); 

imageView.setImageBitmap(bm); 

我不知道它的好,但它的logcat的是沉默。

相關問題