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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -