I am setting an imageview to an image from the sd card. This runs smoothly on the android emulator 4.1, however on the emulator with android version 2.2 it returns a failed binder transaction. I find this very odd and can not figure out what the problem could be. The image image is set the following way:
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);
}
I have already tried options.inSampleSize = 4; but that did not solve the problem.
Thanks for any explanations and help.
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
For code like yours, this usually means that the bitmap is too large. You are limited to 1MB per Binder-based IPC transaction. I am not aware that this limit was raised in Android 4.x, though that is certainly possible.
Hence, make sure that
setImageViewBitmap()uses a small enoughBitmap.