0

I have an application on android with PhoneGap. when I open the app, called the OnCreate. when I leave the app, let it work in the background and after 10 to 15 minutes, turn and enter the app called OnCreate again.

and change the configorientation.

help, thanks

  • The app is probably getting shutdown after you leave the app. Android will close apps to free memory if it needs to. – Andi Jay Aug 17 '12 at 16:41

2 Answers2

2

The Android developer documentation makes reference to an application being in a “killable” state. While Android tries to keep the process of an application resident even after it has exited (i.e. after onDestroy), it does need to be able to kill these processes in low-resource situations to reclaim memory. The states in which an application is killable differ per OS version. On all versions of Android, applications that have returned from onStop or onDestroy are silently killable. On versions of Android prior to Honeycomb, applications that had returned from onPause were also killable. Being killable simple means that Android reserves the right to terminate your application’s process at any time without running even another instruction of your app’s code. In other words, if you have any state that must be recoverable (such as a player’s game progress, items, awards, etc) you must save those to persistent storage no later than the last callback before entering a killable state.

In addition, while applications can run native threads even when they are in a killable state and even post-onDestroy, this is to be avoided, since the process kill will also kill those threads. This could cause all manner of corruption and shutdown issues.

Source

jnthnjns
  • 8,962
  • 4
  • 42
  • 65
0

Android reclaims memory as it is needed from background apps so it is destroying your application and when you reopen it, it restarts thus the onCreate call.

Luke
  • 1,069
  • 18
  • 28
  • It's not really something you can fix, it's built into Android. If you could edit your question for why you need the activity to keep running, you may get more help. I have a feeling you're trying to do something that would be best served using a service. – Luke Aug 17 '12 at 16:46