How to stop a program running under Eclipse?

AndroidEclipseAndroid Emulator

Android Problem Overview


I can't find an option to stop a running program (whether in debug or release mode).

So for now, I stop the program (returning control to Eclipse) simply by closing the emulator.

Is there a better way of doing this? Such that I don't need to close (and restart) the emulator?

Android Solutions


Solution 1 - Android

I understand you want to stop your app on the emulator. For this you can open up the devices window (in the debug perspective), select the process and then press the stop button on the same window.

Solution 2 - Android

Those who find it tedious switching between perspectives to stop the program (like I did), you can view the devices windows in your current perspective by selecting

> Windows > Show View > Other... > Android > Devices

Solution 3 - Android

Keep in mind that on Android, programs generally only 'stop' if you finish() or the system destroys them when memory is required. Why stop at all? You do not need to stop to fix/re-install/re-test, for example.

Solution 4 - Android

In the "Debug" perspective, select the root of the application under "Debug" (where the listing of active threads is) and click the stop button.

Solution 5 - Android

Working for me.

Windows -> Open perspective -> Other... -> DDMS

  1. In the Android view, on the left windows, you can see "Devices". There should be a list of applications that is running now (Emulator or physical devices). Click on the application you want to close. Normally the name is the name of the package + the name of the application
  2. Now click on the symbol of "Stop".

To come back to the normal view, you just have to press on the Java button on the top right side. You can also do it pressing: Windows -> Open perspective -> Other... -> Java

Solution 6 - Android

this answer doesn't deal with Eclipse, but since this question comes up in a Google search for stopping a running Android program, I'd like to offer a command-line method. run adb shell, find the PID of the process you want to kill with ps, for example mine was:

u0_a46 2097 37 175520 19912 ffffffff 40037ebc S net.unternet.bleah.blarg

so then just kill 2097 and you should see the main screen show up again.

Solution 7 - Android

Add breakpoint to your code where you want to stop and then run it in Debug mode by pressing F11.

Solution 8 - Android

Android Zombies Figure 1 - Many Zombies were killed during the research of this Answer

Killing an Android application Java VM process at the OS level is not recommended. Unfortunately, this is exactly what the eclipse device window "stop" does, as does System.exit() and the shell "kill" command.

This subverts the normal app life-cycle methods such as onStop(), onDestroy(), and finalize().

Many apps require these methods for graceful exit (for ex. if they use system objects like Sensor, MediaPlayer, Equalizer, Visualizer, etc).

These system objects hang around with zombie death grips on system resources if release() is not called explicitly during these life-cycle methods. See fig. 1 above. This can prevent an app from restarting, and even require a reboot. That is the ungraceful aspect.

The only solution is to make sure you always exit your app cleanly with a call to onStop() or onDestroy() or at least finalize(). The debugger does this, as does the OS on shutdown.

You can set your app to trap SIG_HUP events in order to force a graceful exit from the command line.

The only time you would kill the app VM is in ANR (already a zombie) state. ANRs must be fixed. Never deploy an app that can enter this state. It is extremely rude.

You can use Google analytics and the Play Store to monitor for these in deployment. You don't want angry users giving single star ANR reviews after having to reboot due to your zombie application. Very bad.

Remember that Android is Linux: treat it like a real OS, and respect the app life-cycle otherwise you shall surely face the dreaded Zombie Apocalypse.

PS: If you don't like the Zombie analogy, how about Fantasia?

enter image description here

Solution 9 - Android

See picture:

  1. Click on DDMS;
  2. Select current app;
  3. Click on "Stop" enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAndroid EveView Question on Stackoverflow
Solution 1 - AndroidVarunView Answer on Stackoverflow
Solution 2 - AndroidGeekityGeekView Answer on Stackoverflow
Solution 3 - AndroidDJCView Answer on Stackoverflow
Solution 4 - AndroidChris ThompsonView Answer on Stackoverflow
Solution 5 - AndroidZain AliView Answer on Stackoverflow
Solution 6 - Androidjcomeau_ictxView Answer on Stackoverflow
Solution 7 - Androidsalman khalidView Answer on Stackoverflow
Solution 8 - AndroidDominic CerisanoView Answer on Stackoverflow
Solution 9 - AndroidEugene BosikovView Answer on Stackoverflow