Android How to end a process, I tried to use the Activitymanager.killbackgroundprocesses method to end, but no response

Source: Internet
Author: User

 after android2.2, if the service added start itself in OnDestroy, with kill backgroudprocess usually cannot end themselves. There is a newly discovered method that uses reflection to call Forcestoppackage to end Process method Forcestoppackage = Am.getclass (). Getdeclaredmethod ("Forcestoppackage ", String.class); forcestoppackage.setaccessible (true); Forcestoppackage.invoke (AM, yourpkgname); Need to add shareduid definition in manifest android:shareduserid= "Android.uid.system" plus permission <uses-permission android:name= " Android.permission.FORCE_STOP_PACKAGES "></uses-permission> with system platform signature because Force_stop_packages permissions are required, This permission is only given to the system signature level program can be implemented to force stop the specified program there is also a way to take advantage of the Linux kill-9 command I also see on the Internet, specific can not, you try it 

Reference: http://blog.csdn.net/Zengyangtech/article/details/5733631



End the entire application process
Activitymanager manager = (Activitymanager) getsystemservice (Context.activity_service);
Manager.killbackgroundprocesses (Getpackagename ());

Android How to end a process, I tried to use the Activitymanager.killbackgroundprocesses method to end, but no response

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.