Keep an App running background

Monkey Targets Forums/Android/Keep an App running background

golomp(Posted 2012) [#1]
Hi,

I tought an App was running when i use Home button but it doesnt work:
I made a little App wich just add 1 to x and display x value.
when i press home and comeback few seconds after with the task manager,
i observe the count was stopped and continue just "because i am back".

I search on web and i tried to put in manifest file a clause:
android.persistent="true". It compile but it did'nt change.

I also read it's possible to create a service and obtain an App running
background but i don't know if it's possible with Monkey.
Even if it's possible, how to stop this service once is running...

If anyone have an idea...


therevills(Posted 2012) [#2]
Monkey/Mojo overrides the onPause method of the Android Activity to actually suspend the Monkey game.

If you want to keep the game running you will need to remove this code - but I am not 100% sure that your game will always be running as Android OS may actually remove it from memory if resources are low (to allow other applications to run).


AdamRedwoods(Posted 2012) [#3]
I also read it's possible to create a service and obtain an App running
background but i don't know if it's possible with Monkey.

http://developer.android.com/reference/android/app/Service.html

this would require your own OS native implementation since monkey's requirement is to be cross-platform.


golomp(Posted 2012) [#4]
Thank you for your answers.

You mean that even in Pause, the game can be removed by android system if it need memory ?...ok...

About memory, what maximum size of SaveState String is possible ?


Volker(Posted 2012) [#5]
http://www.monkeycoder.co.nz/Community/posts.php?topic=1551


golomp(Posted 2012) [#6]
Thank you Volker, i think my app will not arrive to feed completely
SaveState String... ;) (maybe not even 10%)