문제

I saw similar types of posts here.But i am not getting this right.To get the UID of running process i wrote

ActivityManager mgr = (ActivityManager) context.getSystemService(ACTIVITY_SERVICE);
List<RunningAppProcessInfo> processes = mgr.getRunningAppProcesses();
String text = "All Process:\n";
for (int i = 1; i <= processes.size(); i++)
{
    String s;
    s = processes.get(i - 1).processName.toString();
    text += "Process:" + i + s + ":UID:" + android.os.Process.getUidForName(s) + "\n";
}

But after completion of loop what i am getting in the string text is all UID value as -1.I put GET_TASKS permission in manifest file.Why i am not getting the UID.Please help.I need this UID to kill the process.

도움이 되었습니까?

해결책

To kill the process i used killBackgroundProcess Method of ActivityManager.It needs package name not the UID

다른 팁

Please see this answer by @seanhodges for reference.
Reading the whole thread might be helpful too.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top