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>
Related
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
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.
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());
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/
I would like to crash my Android app by using command-line ADB tool during my app is running, is it possible to do? and how ?
(Basically, I want to test if my app persist the necessary informations when it is crashed. So, I would like to demo this by crash my app by some command-line tool, like ADB.)
***** Update ********
In other words, how to kill my app process by using ADB tool?
kill probably won't work.
adb shell am force-stop <your.app.package>
adb shell kill <PID>
Try the below command in abd shell.
You can kill your app from the shell:
adb -s YOURDEVICEID shell
top // find your app pid
kill -p YOUR_APP_PID
I can easily kill my app from Eclipse DDMS. Just stop the process , e.g. stop "com.my.app"
You can actually trigger a crash via the "crash" param to adb shell am
adb shell am crash <package name>
This is an obscure option but can be confirmed when emulator is running via: adb shell am help
Details: reference
crash [--user <USER_ID>] <PACKAGE|PID>
Induce a VM crash in the specified package or process
Wish this was easier to find I cannot find the original source where I found it but should be more obviously listed on docs page vs only shown when connected am help menu...
https://developer.android.com/studio/command-line/adb#am
App crashing at runtime is nothing but an Occurance of Exception, The place after which you want to crash your app, write a logic which causes for an Exception.
The best way to crash your app is to add an Exception to your package.
Like division by 0 - add it to your app code.
I don't know if you've got the answer yet. The answer is pretty much the same as #bas but instead of using , you need to you the package name
adb shell am force-stop <package name>
you can get the package name by using this command
adb shell pm list package -3
-3 means all 3rd party apps that are installed in device.