I have an icon that is loaded from the app manager. It is normally small, usually 48x48. I save this icon and load it back later on.
Some users are reporting problems when I try to load the saved icon. This occurs for different icons for different users and the only common denominator is that they all have phones running Android 1.5 (Sprint Hero, Sprint Moment, Droid Eris).
//Returns a valid drawable 100% of the time
Drawable drawable = activityInfo.loadIcon(manager);
//Creates a bitmap 100% of the time
Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
//This drawable can always be displayed (so you know the bitmap is good here.
Drawable testDrawable = new BitmapDrawable(bitmap);
//There are no errors thrown from these lines but in ALL cases if it fails the length of the byte[] array b is 48.
//When it succeeds the length is much bigger 1000+.
ByteArrayOutputStream out= new ByteArrayOutputStream();
bitmap.compress(CompressFormat.PNG, 0, out);
byte[] b = out.toByteArray();
I can easily tell that the users icon failed to load because you cannot create a valid bitmap back from the 48 length byte array.
What can I change in the 3 lines that create my byte array to fix the problem? I have also tried, with nochange:
bitmap.compress(CompressFormat.PNG, 100, out);