Search code examples
androidxamarin.android

How to kill application process?


In my Xamarin.Android application, I have code that handles restoring state after process death (when the OS kills the application to free memory). I want to test this code but I do not know how to simulate when my application process gets killed. I am trying to do it through the terminal. From my platform-tools folder:

drake@Drakes-MacBook-Pro platform-tools % ./adb shell
generic_x86:/ $ am kill com.mycompany.myapp

But this is not working. And I think it is because it is not targeting the OS in my emulator. I was expecting to see "Pixel_C_API_30" instead of "generic_x86". I am on a Mac.


Solution

  • You can use the adb device command to list the device.

    If you have multiple devices, you can use -s to specify the device XXX like this: adb -s XXX shell