I think what you need to do is display Thumbnails
instead of bitmap image on your screen. You can generate Thumbnails and display as per your size requirements. And whenever user click on Thumb
, just take original path and set wallpaper.
Another option is you can use Universal Image Loader which helps you to buffer your image in disc (like SD card
or your application's Internal memory
). So issue of Out of Memory
can be resolved.
And also for best practice to display Bitmaps, Displaying Bitmaps Efficiently will helpful.
Edit:
Use following configuration for your application. This will cache images inside cache directory of application.
File cacheDir = new File(this.getCacheDir(), "cwac");
if (!cacheDir.exists())
cacheDir.mkdir();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
CWAC.this)
.threadPoolSize(5)
.threadPriority(Thread.MIN_PRIORITY + 3)
.denyCacheImageMultipleSizesInMemory()
// .memoryCache(new UsingFreqLimitedMemoryCache(2000000)) // You
// can pass your own memory cache implementation
.memoryCacheSize(1048576 * 10)
// 1MB=1048576 *declare 20 or more size if images are more than
// 200
.discCache(new UnlimitedDiscCache(cacheDir))
// You can pass your own disc cache implementation
//.defaultDisplayImageOptions(DisplayImageOptions.createSimple())
.build();