androidandroid-servicewear-os

How to simulate a service killed by the Android system


While developing I wanted to test the situation where the system kills a service. This is because I'm loosing connection when communicating between the Android Wear and the handheld. And I think that it is related with the system killing some services.

Does anyone have a suggestion on how to approach this?


Solution

  • if you're developing in Android Studio while you are running your application in android wear side try to hit the kill button displayed in the console.

    Kill app button

    When you hit this button all the threads + services + activities from this app will be destroyed. If your service is of type "STICKY" it will start by itself after you kill your application.