Force close other applications, you can use Activitymanager, first need to obtain (Activitymanager) Getsystemservice (Context.activity_service);
You can then call its function to close the operation, and there are two ways to do so:
1. void killbackgroundprocesses (String packagename): This method is described in the API of the Android website, after the kill, the closed application will be restarted.
The system immediately kill all background processes associated and the given package. The same as the kernel killing those processes to reclaim memory; The system would take care of restarting these processes in the future as needed.
Use: Requires permission: <uses-permission android:name= "Android.permission.KILL_BACKGROUND_PROCESSES"/>
2. void Forcestoppackage (String packagename): This method is not currently available on the Android website API, I do not know why ah ...
Use:
requires permission: android:shareduserid= "Android.uid.system"
<uses-permission android:name= "Android.permission.FOCE_STOP_PACKAGES"/>
Your own implementation of the Code:
Activitymanager Activitymanager = (Activitymanager) Getsystemservice (Context.activity_service); Activitymanager.forcestoppackage ("Com.android.scan");
It is recommended to use the 2nd type ...
Reference: http://blog.csdn.net/huxueyan521/article/details/8921976
http://blog.csdn.net/mingli198611/article/details/7057615