Last Updated: February 25, 2016
· darrenhinderer

Easily test state loss in Android

Once your app gets reasonably complicated, saving state will become an issue. Sure you have onSaveInstanceState available, but how do you test it?

Within the first few hours of developing on Android you probably learned about orientation changes causing state loss within an activity. But a larger issue crops up if your app is completely torn down and later resumed.

It is a likely scenario the user will take a phone call with your app open, then try to go back to using your app. Meanwhile Android has killed your process. And when the phone call is over, all of your statics are gone, and any initialization code needs to be re-run. An orientation change will not correctly simulate this process.

Enter Shakabuku:

This little widget kills your process, and resumes right where you were inside of the app. I hope it saves you some time while tracking down state loss issues.