Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulating activity death in Android

We know that when the system runs out of resources, an activity in background serializes its state and gets killed by the OS. When we resume it, the OS recovers the activity state by savedInstanceState passed to onCreate method. Considering we are responsible for handling what is going to be serialized/recovered, I'd like to have my activity killed in order to test the code I created for recovering. How can I achieve that? Forcing the application to be killed through the applications menu doesn't help.

like image 992
Flávio Faria Avatar asked Mar 04 '11 20:03

Flávio Faria


1 Answers

Rotate your device (or emulator). Android saves, destroys, and re-creates the activity in the new orientation.

like image 168
Darrell Avatar answered Sep 19 '22 18:09

Darrell