I want kill another app's server by ActivityManager.RunningServiceInfo in third app. eg,some app's service I want keep alive,else service(NOT fit for Service START_STICK) will be killed. here is my code:
ActivityManager actManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); List killapplist = actManager.getRunningAppProcesses(); List killservicelist = actManager.getRunningServices(100); for (Object aKillapplist : killapplist) { ActivityManager.RunningAppProcessInfo localRunningAppProcessInfo = (ActivityManager.RunningAppProcessInfo) aKillapplist; String appname = localRunningAppProcessInfo.processName; if (localRunningAppProcessInfo.pkgList != null) { for (Object aKillservicelist : killservicelist) { ActivityManager.RunningServiceInfo localRunningServiceInfo = (ActivityManager.RunningServiceInfo) aKillservicelist; //some condition start try { Intent intentstop = new Intent(); intentstop.setComponent(localRunningServiceInfo.service); mContext.stopService(intentstop); } catch (SecurityException e) { e.printStackTrace(); } //some condition end } } } } else { throw new MyException("kill list is empty"); } then always get warn msg
WARN/ActivityManager(363): Permission Denial: Accessing service ComponentInfo WARN/System.err(5992): java.lang.SecurityException: Not allowed to stop service Intent is the problem of sys signature ? I used some permission
uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" uses-permission android:name="android.permission.SHUTDOWN" uses-permission android:name="android.permission.FORCE_STOP_PACKAGES" how to fix it? thanks