I have two different apps, this hypothesis two apps are A and B. there are many service at A app,my task is want to kill the service of A using method of B, but A and B are not apk ,are different apps.
i used :
ActivityManager manager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
List<RunningAppProcessInfo> activityes = ((ActivityManager) manager).getRunningAppProcesses();
for (int i = 0; i < activityes.size(); i++){
Log.e("APP: "+i, activityes.get(0).processName);
if (!activityes.get(i).processName.contains("com.qihoo360")){
//android.os.Process.killProcess(activityes.get(1).pid);
Log.i("dfd","xx");
manager.killBackgroundProcesses("com.qihoo360.mobilesafe");
android.os.Process.sendSignal(activityes.get(1).pid, android.os.Process.SIGNAL_KILL);
}
}
but no useful.but at mobile setting manager App ,it have a close button to close it. if i no authority to kill another app because System security.
You should look at intent-filters. Make sure your application has permission to access the service and you other application. Hopefully this link could help you out: http://justanapplication.wordpress.com/2011/02/16/the-android-intent-based-apis-part-five-services-and-intents/
You should not even attempt to kill the service in this manner.
Use a broadcast receiver in the service to be stopped and send a broadcast from the app that wants to stop it.
This lets the receiver decide if it is finished and release resources gracefully.
You should have an extremely good reason to even attempt to forcibly kill processes.
You should refer to the source code of how services are killed before you even attempt this. This will help you figure out what you need.
DONT try coding without some structure on what you're trying to do, and how you can achieve it.