How does Android end a process? I tried to use ActivityManager. killBackgroundProcesses to end the process, but no response was returned.
After android2.2, if start itself is added to the ondestroy service, kill backgroudprocess usually cannot end itself. There is a newly discovered Method that uses reflection to call forceStopPackage to end the process Method forceStopPackage = am. getClass (). getDeclaredMethod (forceStopPackage, String. class); forceStopPackage. setAccessible (true); forceStopPackage. invoke (am, yourpkgname); you need to add the shareduid in manifest to define android: sharedUserId = android. uid. add additional permissions to system
And the system platform signature is used because the FORCE_STOP_PACKAGES permission is required, this permission can only be granted to the system signature-level program to force stop the specified program. There is also a way to use the kill-9 command in linux. I also read it online. The specific operation is not feasible. Please try it.
// End the entire application process
ActivityManager manager = (ActivityManager) getSystemService (Context. ACTIVITY_SERVICE );
Manager. killBackgroundProcesses (getPackageName ());