Reputation: 253
I am accessing images from android resources folder. i am using asynctask to load images.
On first time i used images with resolution of 1024*768 the app opens and one by one image is shown into imageview.
on second time, For experiment i used images with resoltion 1920*1080 the app is giving runtime error and force closed. The same happens with image resoltion of 1280*720.
but it perfactly runs with 1024*768 resolution why this happens????
i m not posting code cause it doesn't seem to have programatical issue.
Upvotes: 0
Views: 1783
Reputation: 18977
Simply you got Out Of Memory exception
because your image size is large, consider this calculation:
In order to show each pixel in ARGB_8888
we use 4 bytes so:
your first image: 1024 * 768 * 4 = 2MB
your second image: 1920 * 1080* 4 = 6MB
your third image: 1280 * 720 * 4 = 3MB
I do not know how many images you are loading to your RAM
but your RAM
is limited and it is at least 16MB
so with other 4-5 images you will have no RAM
to other objects. look at
Loading Large Bitmaps Efficiently to solve your issue.
Upvotes: 2