Reputation: 3
I want force close another specify app , the same as "Setting" -> "Apps" -> "my app name" -> "Force stop" , I try it with 2 ways , as follows: 1. ActivityManager forceStopPackage
Method forceStopPackage;
forceStopPackage =am.getClass().getDeclaredMethod("forceStopPackage",String.class);
forceStopPackage.setAccessible(true);
forceStopPackage.invoke(am, "this is the specify package name");
the code is like this
android.os.Process.killProcess("this is a pid that I got from the Running specify app"); android.os.Process.sendSignal(pid, Process.SIGNAL_KILL);
But,both not works, I have no idea,and I need your help.
Upvotes: 0
Views: 267
Reputation: 8641
One hopes that you can't do this unless you've rooted your phone. We should all realize that being able to kill another app, even one that we "own", is a horrible security risk. Killing any app, even your own app, is not a good idea, because you're taking control out of the hands of the user. That's why task killers are so not Android.
Upvotes: 2
Reputation: 722
your app doesn't have system permission, you can't kill other app process else your app got root permission.
Upvotes: 0