我的论文中有一个问题,关于 BATTERY DOCTOR SAVER 我的问题是什么,.api列表,我想要的只是运行不是内部的应用程序系统因为在我的论文中它也显示了内部系统。有没有办法在我们的任务杀手中删除内部系统?到目前为止,这是我获取正在运行的应用程序的代码:
public void loadRunningProcesses() {
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
List<RunningAppProcessInfo> appinfolist = activityManager
.getRunningAppProcesses();
Log.d(TAG, "AppInfoList Size: " + appinfolist.size());
for (ActivityManager.RunningAppProcessInfo runningAppProcessInfo : appinfolist) {
TaskObject runningtask = new TaskObject();
runningtask.setPid(runningAppProcessInfo.pid);
runningtask.setProcessName(runningAppProcessInfo.processName);
adapter.addTask(runningtask);
runningtask.setProcessName(runningAppProcessInfo.processName.substring(11));
runningtask.setProcessName(runningAppProcessInfo.processName);
}
}
class TaskObject {
int pid;
String processName;
private boolean toKill;
public int getPid() {
return pid;
}
public void setPid(int pid) {
this.pid = pid;
}
public String getProcessName() {
return processName;
}
public void setProcessName(String processName) {
this.processName = processName;
}
public boolean isToKill() {
return toKill;
}
public void setToKill(boolean toKill) {
this.toKill = toKill;
}
}
答案 0 :(得分:0)
我已经找到了解决这个问题的方法。我只使用子字符串,并使第一个字母成为正式的大写字母,看看我的代码:
for (ActivityManager.RunningAppProcessInfo runningAppProcessInfo : appinfolist) {
TaskObject runningtask = new TaskObject();
String ringgo = new String();
ringgo = runningAppProcessInfo.processName.toLowerCase().trim();
if (!ringgo.equals("system")){
if (ringgo.length()>12){
runningtask.setPid(runningAppProcessInfo.pid);
runningtask.setProcessName(ringgo.substring(12).substring(0,1).toUpperCase()+ringgo.substring(13));
adapter.addTask(runningtask);}
else{
runningtask.setPid(runningAppProcessInfo.pid);
runningtask.setProcessName(ringgo.substring(0,1).toUpperCase()+ringgo.substring(1));
adapter.addTask(runningtask);
}
}
}
}