Why adb shell am kill <PACKAGE_NAME> doesn't kill process? - android

I want to kill app process of my app for testing purpose. I want to test activity restoration.
I send my app to background by pressing home button. Then I run this command adb shell am kill <PACKAGE_NAME> in Android Studio terminal, but it doesn't kill app process.

Use force-stop instead
adb shell am force-stop package-name

Related

How to close android application completely using adb or appium or any command line+python

I have tried to close android application using adb command and appium server but it is minimizing the app, not closing. I used below command for closing.
adb shell am force-stop com.package.name
AND if i try this command to kill process then it says,
adb shell kill 21860
Error:Operation omitted
Please let me know any way or command line to close android app completely, not run in background.
Thanks in advance!
I don't want to see in the background application list like below image.
adb shell am force-stop <PACKAGE-NAME>
Force stopS everything associated with <PACKAGE-NAME>
should work since honeycomb
Why not just:
un-installing app (it will stop any service or running process of it):
adb -s <udid> uninstall <appPackage>
and then installing it again:
adb -s <udid> install <apkPath>
Note:
In my case it is not working, because my app need to be registered each time re-installed, and working around it with 3rd app (e.g. Appium) is taking too long.

How to kill any android applications from a terminal shortcut?

I have this new app that I got from the Play store which allows me to make shortcuts for certain actions. For my likings, I want to make it so that if I hold the volume up button, it would kill the app. (Not minimize, but kill). It doesn't have that option but it does have an option to have a terminal emulation shortcut.
Please help. Thanks
killing the app:
adb shell am kill com.myapp.package
stopping the app using adb:
adb shell am force-stop com.myapp.package
more info:
https://developer.android.com/tools/help/adb.html#am
You can use am force-stop <package name> and am kill <package name>

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

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?
The first way
Requires 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.
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 <USER_ID> | all | current: Specify user whose processes to kill; all users if not specified.
The fourth way
Requires 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.
If you have a rooted device you can use kill command
Connect to your device with adb:
adb shell
Once the session is established, you have to escalade privileges:
su
Then
ps
will list running processes. Note down the PID of the process you want to terminate. Then get rid of it
kill PID
If you want to kill the Sticky Service,the following command NOT WORKING:
adb shell am force-stop <PACKAGE>
adb shell kill <PID>
The following command is WORKING:
adb shell pm disable <PACKAGE>
If you want to restart the app,you must run command below first:
adb shell pm enable <PACKAGE>
To kill from the application, you can do:
android.os.Process.killProcess(android.os.Process.myPid());

How to stop all background processes in android?

I hope to stop all backgroud processes.
I got to know that adb shell am kill-all may do this job. I exit one application by pressing BACK,
then I enter adb shell am kill-all, However, I find the process by entering adb shell ps | grep packagename.
Does adb shell am kill-all really work?
If you don't have to kill background process with adb shell command. You can use some task manager in play store.
I also developed a task manager by myself, there are source codes:
https://code.google.com/p/my-test-project-lion/

How to exit APK from shell

I know how to start an APK from the shell using this command:
adb shell am start -a android.intent.action.MAIN -n package name/activity name
Is there a way to quit the apk using shell commands? Thanks!
Try:
adb shell am kill com.blah.foo
From help docs: "am kill: Kill all processes associated with PACKAGE. Only kills processes that are safe to kill -- that is, will not impact the user experience."
In other words: If you are actively using the application this will not kill it. It will only kill an application that is ready to be killed.
So if you wish to kill an application that is actively running use:
adb shell am force-stop com.blah.foo
This will close it without regard to what it affects
I just used ps to find the PID of the process.
Then I used kill [pid] to kill that process.
This worked, but if there is any other way, help would be appreciated!

Categories

Resources