Android development, sometimes we need to test the background process is killed, and then re-enter the app to restore the scene case. If the way to fill the memory is more troublesome, here are a few quick simulations of how the background process was killed:
Mode 1:
The easiest way to do this is to click "Stop porcess" in Ddms to Kill your program, which you can do when you debug the program.
Mode 2:
Suitable for debug programs
Open Android Monitor in Android Studio, select the process, press the app to back to the background, click the Terminate Application button
Mode 3:
The ADB shell am force-stop package-name app is forcibly closed in the foreground, forcing the specified package pack app to stop.
ADB shell AM kill Package-name app has been stuck in the background using the home key, killing the specified package app process, which kills processes in safe mode without impacting the user experience. Parameter options:--user <USER_ID> | All | Current: Specifies that the user process kills if the default is not specified for all users. (about user_id will be introduced below)
ADB shell am Kill-all app through the home button has been stuck in the background use, kill all background programs, need to first the target program to enter the background, and then open a other program
Mode 4:
For All Programs
Open Mobile Developer Options-Background process restrictions-do not allow background processes, also press the home key back to the background, open another app and then quit, the process was killed.
Mode 5:
Via simulator or a root-based real machine:
1. Press the home button to exit your program;
2. In the console, enter the following command (Windows system WIN + R-cmd)
Find the app's process ID adb shell PS
Find your app's package name
MAC/UNIX:ADB Shell PS | grep your.app.package
After following the above command, it looks like this:
USER PID PPID vsize RSS wchan PC NAME # u0_a198 21997, 827940 22064 ffffffff 00000000 S your.app.package
Kill your app with the PID kill-9 the ADB shell 21997
Android simulation app kills command due to low memory