10

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?

Fábio Carballo
  • 3,185
  • 5
  • 20
  • 36

4 Answers4

6

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.

Dr.jacky
  • 2,499
  • 6
  • 41
  • 76
cdlc
  • 193
  • 8
0

cdlc's answer works, but another way is if you're developing in Android Studio you can go to DDMS: Tools->Android->Android Device Monitor and press the stop button there and you will also see a sticky service restart.

CSchwarz
  • 390
  • 1
  • 13
0

If you check the developer options on an Android phone, there will be an option to show the running services. Under that option you can choose to stop any service that is running.

0

As of 2020 we have to do it manually (since we don't have Android Monitor or DDMS anymore).

This was tested on Linux. You need root permission for the device (how to get root for an AVD).

  1. Getting the PID (first number): adb shell ps | grep -i <package-or-part-of-it>
  2. Killing the process: adb shell kill <your-PID>
MattSchmatt
  • 528
  • 4
  • 15