How does Android end a process? I tried to use ActivityManager. killBackgroundProcesses to end the process, but no response was returned.

Source: Internet
Author: User

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 ());

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.