我正在将 imageview 设置为来自 sd 卡的图像。这在 android 模拟器 4.1 上运行顺利,但是在 android 2.2 版的模拟器上它返回失败的活页夹事务。我觉得这很奇怪,无法弄清楚问题可能是什么。图像图像设置如下:
try{
String pathName = Environment.getExternalStorageDirectory().getPath() + "/Drop Insight/" + c.getString(iID) + ".png";
File path = new File(pathName);
if(path.exists()){
BitmapFactory.Options options = new BitmapFactory.Options();
Bitmap bm = BitmapFactory.decodeFile(pathName, options);
remoteView.setImageViewBitmap(R.id.ivwidgetimage, bm);
}
else{
remoteView.setImageViewResource(R.id.ivwidgetimage, R.drawable.defaultpic);
}
}
catch (Exception e) {
Log.e(DEBUG_TAG, "Failed", e);
}
我已经尝试过 options.inSampleSize = 4; 但这并没有解决问题。
感谢您的任何解释和帮助。
11-25 19:22:04.992: D/dalvikvm(59): GC_EXPLICIT freed 3148 objects / 171272 bytes in 107ms
11-25 19:22:05.092: V/MediaProvider(216): /mnt/sdcard volume ID: 318247957
11-25 19:22:05.201: D/dalvikvm(282): GC_EXTERNAL_ALLOC freed 989 objects / 66344 bytes in 59ms
11-25 19:22:05.391: E/JavaBinder(59): !!! FAILED BINDER TRANSACTION !!!
11-25 19:22:05.401: D/dalvikvm(153): GC_EXPLICIT freed 4139 objects / 251136 bytes in 1278ms