0

Hi I am developing an android magazine application.

It has many pictures. In application I show each picture in full screen and the user can swipe between pictures.

I used ViewPager with FragmentStatePagerAdapter. Every thing works fine. When I rotate the device first time it also works fine.

But if I try it several times it give an error. The error is outofmemoryerror.

The adapter for viewpager in horizontal and in portrait is different.

Anybody help what can I do?

Shrikant Ballal
  • 7,067
  • 7
  • 41
  • 61
nebyan
  • 9,347
  • 1
  • 20
  • 20

1 Answers1

1

If you are using Bitmaps, the memory held by Bitmap doesn't get freed by GC, we manually have to release the memory by calling bitmap.recycle().

Please see my answer on same issue: bitmap size exceeds Vm budget error android

It has generic answer to this issue.

Community
  • 1
  • 1
Shrikant Ballal
  • 7,067
  • 7
  • 41
  • 61
  • I have solved the problem. When the orientation of the device changed the FragmentPagerAdapter shows page from 0. I prevent creating from page 0. It create page where I need. for example my page number in landscpae is 5 when I turn device in portrait I must show again page number 5. But FragmentStatePagerAdapter shows page from 0 and 1. – nebyan Oct 02 '12 at 13:59
  • This is a different question. Please ask this question separately. Please accept this answer if it has solved your first problem. Thank you :) – Shrikant Ballal Oct 03 '12 at 08:20