OnSuspend / OnResume

Monkey Forums/Monkey Programming/OnSuspend / OnResume

Xaron(Posted 2011) [#1]
Dear all,

I just scratch my head what needs to be done in OnSuspend and OnResume resource wise?

I've noticed that I get a Monkey exception due to an out of memory error for my bitmap resources on Android AFTER I've pressed Home on the device and enter the app again. In the first run everything is ok.

So what has to be done here? Originally I thought this would be obviously useful to make something like SaveState and LoadState but this doesn't seem to be enough?!

What exactly happens when an app is suspended and resumed? Is the OnCreate method called again? I noticed that I have to cache all graphics (on Android) again to remove this draw delay problem.


FlameDuck(Posted 2011) [#2]
I've noticed that I get a Monkey exception due to an out of memory error for my bitmap resources on Android AFTER I've pressed Home on the device and enter the app again. In the first run everything is ok.
This is almost certainly a bug. You should post it in the bug forum. Related info.

When the screen orientation changes the system will, by default, destroy the current activity and create a new one while preserving its state. In doing so, Android will reload the application's UI from the resources. Now imagine you wrote an application with a large bitmap that you don't want to load on every rotation.
The same thing happens when you press Home on Android. It can either be a bug in monkey, or it can be a bug in your code (if you have any Global's for instance). Do you have a Java file I can look at?


Uncle(Posted 2011) [#3]
Hi, sorry to raise this from the grave but was this issue been fixed? My game runs fine on my HTC Desire, but I had a report of similar issue on a Galaxy S.


Xaron(Posted 2011) [#4]
Regarding this out of memory thing I found a solution, yes. Mark has added it with Monkey V50.

http://www.monkeycoder.co.nz/Community/posts.php?topic=1894