Issue
From my app I am trying to get from other installed apps a specific drawable resources. The resource always exist. I use :
Resources resources = activity.getPackageManager().getResourcesForApplication(packageName);
int previewResID = resources.getIdentifier("image", "drawable", packageName);
Drawable myThemePreview = resources.getDrawable(previewResID);
I get the out of memory on the last line before drawable converted to bitmap and shows up to user
Solution
You could use BitmapFactory::decodeResource using with a BitmapFactory.Options with a specified inSampleSize to reduce memory.
It would look something like this:
Resources resources = activity.getPackageManager().getResourcesForApplication(packageName);
int previewResID = resources.getIdentifier("image", "drawable", packageName);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 4;
Bitmap bitmap = BitmapFactory.decodeResource(resources,previewResId,options);
Answered By - cwbowron
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.