android - Out of memory when trying to get drawable resources from other apps -


from app trying other installed apps specific drawable resources. resource exist. use :

resources resources = activity.getpackagemanager().getresourcesforapplication(packagename); int previewresid = resources.getidentifier("image", "drawable", packagename); drawable mythemepreview = resources.getdrawable(previewresid); 

i out of memory on last line before drawable converted bitmap , shows user

you use bitmapfactory::decoderesource using bitmapfactory.options specified insamplesize reduce memory.

it 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); 

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -