user317033
user317033

Reputation:

How to test your app being killed and restarted?

I'd like to test the case of my app being killed and restarting in a non main activity pretending to the user that the app was simply resumed. Anyone know how to do this? None of the ideas I've found work as they all kill the app which then resumes at the main activity.

Upvotes: 2

Views: 181

Answers (2)

user317033
user317033

Reputation:

I actually found this more convenient. Your app is killed and restarted in the previous activity, so just add a debug button to call this:

System.exit(0);

And if you want to restart in the current activity, just start another activity then immediately call this.

Upvotes: 0

fedepaol
fedepaol

Reputation: 6862

If you have a ics phone (or in the emulator) just activate

don't keep activities

option.

From the doc:

Tells the system to destroy an activity as soon as it is stopped (as if Android had to reclaim memory). This is very useful for testing the onSaveInstanceState(Bundle) / onCreate(android.os.Bundle) code path, which would otherwise be difficult to force. Choosing this option will probably reveal a number of problems in your application due to not saving state. For more information about saving an activity's state, see the Activities document.

Upvotes: -1

Related Questions