Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ADB stop application command like "force-stop" for non rooted device

Tags:

android

adb

I'm trying to stop application on Android 2.3.7 device. But in this version of Android I can't use "force-stop" command. Do you know any other ways to close application on non rooted device?

like image 267
Erdem Ergin Avatar asked Jul 24 '13 09:07

Erdem Ergin


People also ask

How do I force quit an application in 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 stop adb from running?

To stop the adb server, use the adb kill-server command. You can then restart the server by issuing any other adb command.

How do I leave 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.


1 Answers

The first way
Needs root

Use kill:

adb shell ps => Will list all running processes on the device and their process ids
adb shell kill <PID> => Instead of <PID> use process id of your application

The second way
In Eclipse open DDMS perspective.
In Devices view you will find all running processes.
Choose the process and click on Stop.

enter image description here

The third way
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). This command kills only processes that are safe to kill and that will not impact the user experience.
Options are:

--user | all | current: Specify user whose processes to kill; all users if not specified.

The fourth way
Needs root

adb shell pm disable <PACKAGE> => Disable the given package or component (written as "package/class").

The fifth way
Note that run-as is only supported for apps that are signed with debug keys.

run-as <package-name> kill <pid>

The sixth way
Introduced in Honeycomb

adb shell am force-stop <PACKAGE> => Force stop everything associated with (the app's package name).

P.S.: I know that the sixth method didn't work for you, but I think that it's important to add this method to the list, so everyone will know it.

like image 175
EvZ Avatar answered Sep 17 '22 11:09

EvZ