Simulate killing of activity in emulator

You can pause your application (by pushing the Home button, simulating a call, whatever). Then kill the app’s process through adb. Since the docs say that after onPause() returns your app can be killed without any further notice, this is a fair test.

If you don’t want to go through the trouble of finding the pid of your app’s process, you can use adb shell am kill com.example.package_name to kill your app’s process. Make sure that the app is put in the background. The docs say that this command “kills only processes that are safe to kill and that will not impact the user experience.” So you might want to launch a couple of other apps before trying this one.

Leave a Comment