I am making an application to display slideshow of images and videos. I am using ViewFlipper to flip videos and images. Moreover, I am using Picasso library to display image from local storage. Now, when I try to run the application at some point it is running perfectly. But once in a while, I a getting the exception Out of memory on a 8294416-byte allocation. I googled it and find one solution that using "android:largeHeap=true" I could solve the issue. But it didn't worked for me. Do anyone knows how to solve it?
Asked
Active
Viewed 761 times
0
-
reduce the size of the image – Francesco verheye May 18 '16 at 08:21
-
How can I reduce it? Can you help me with that? – Dhaval May 18 '16 at 08:22
-
Make the image smaller (width x height px). What size is the image? – Francesco verheye May 18 '16 at 08:23
-
Any specific reason why you're using a ViewFlipper in stead of a ViewPager? – the-ginger-geek May 18 '16 at 08:31
-
@Neil Yes. Actually I have implemented both. But ViewFlipper fits perfectly in my case as I am flipping both images and videos. – Dhaval May 18 '16 at 08:34
-
You can do the same with ViewPager using fragments. I think that may also help solve your memory issue. You can also try using Glide to load your resources. Have you ever had the error while trying ViewPager? – the-ginger-geek May 18 '16 at 08:35
-
No. When I used ViewPager I have only added 15 images at a time. But now I am adding 62 images at a time and getting the exception. – Dhaval May 18 '16 at 08:38
-
The ViewPager recycles the Fragments. You shouldn't get an out of memory issue if you implement it properly. I suggest you switch to ViewPager. – the-ginger-geek May 18 '16 at 08:41
-
@Neil Thank you for your suggestion. Is this exception occurs because of ViewFlipper or size of image? – Dhaval May 18 '16 at 08:43
-
I would say both. Mainly because of the sheer amount of images you're loading into it. ViewPager will solve your problem. Don't think the ViewFlipper recycles views. – the-ginger-geek May 18 '16 at 08:46
-
@Neil Ok. I will try to implement with ViewPager. Thanks again. – Dhaval May 18 '16 at 08:47
1 Answers
2
This is a good training to load large Bitmaps in Android
https://developer.android.com/training/displaying-bitmaps/load-bitmap.html
Edit This is another SO answer which is related to Picasso. Look at .resize(width, height) https://stackoverflow.com/a/23741267/1723525

Community
- 1
- 1

Francesco verheye
- 1,574
- 2
- 14
- 32
-
Thanks. I will go through it. But there are different images in which I am getting this exception. – Dhaval May 18 '16 at 08:26
-
-
-
Thank you. It is working for now. I will test with more images and figure out what will happen. – Dhaval May 18 '16 at 09:06