Search code examples
androidlifecycle

Any way to force app out of memory in Android emulator?


I've implemented application state saving/loading in onSave/RestoreInstanceState and onCreate in one of my android app's activities. Is there any way to force the emulator to remove my app from memory so that onRestoreInstanceState is called?

Currently it looks like my app just stays in memory (for a time longer than I am willing to wait anyway). When I hit the "home" button when my activity is active I get the following method calls:

  • onSaveInstanceState
  • onStop

When I reactivate my app, all I get is

  • onRestart

Is there any way in the emulator to force my app to be mothballed so that onRestoreInstanceState and/or onCreate are called again?


Solution

  • Use the DevTools app ("Immediately destroy activities").