Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emulate Force Stop from ADB/Shell Commands

Tags:

android

shell

adb

Is there a way using the current command line tools (adb, am, pm) to emulate a user pressing Force Stop from the Settings app? Calling kill <pid> from the shell only works so well as to emulate what happens when the system kills a process, but Force Stop does more to remove the memory of an application by removing its ActivityRecord instances that Android saves around.

Is there a shell command we can call to emulate this same behavior?

Cheers.

like image 937
devunwired Avatar asked Jul 16 '12 19:07

devunwired


People also ask

How do I force quit an app using adb?

In Devices view you will find all running processes. Choose the process and click on Stop . It will kill only background process of an application. adb shell am kill [options] <PACKAGE> => Kill all processes associated with (the app's package name).

How do I terminate adb shell?

To exit adb and return to the system shell use the $q or $Q command. To stop the debugger press <Ctrl>D. NOTE: adb cannot be stopped by pressing the Quit or Interrupt key.

What are adb shell commands?

Android Shell Commands. ADB is Android Debug Bridge which is a command line utility included with Google's Android SDK. It provides a terminal interface to control your Android device connected to a computer using a USB. ADB can be used to run shell commands, transfer files, install/uninstall apps, reboot and more.


1 Answers

Use am:

am force-stop: force stop everything associated with <PACKAGE>.

am kill: Kill all processes associated with <PACKAGE>.  Only kills.
  processes that are safe to kill -- that is, will not impact the user
  experience.

for example:

adb shell am force-stop <PACKAGE>
like image 192
Diego Torres Milano Avatar answered Sep 21 '22 18:09

Diego Torres Milano