/**
*
* add timmy 20161220
* clean memory thread
*/
Runnable runnable = new Runnable() {
@Override
public void run() {
if(mActivityManager==null){
mActivityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
}
List<ActivityManager.RunningAppProcessInfo> list = mActivityManager
.getRunningAppProcesses();
if (list != null) {
for (int i = 0; i < list.size(); i++) {
ActivityManager.RunningAppProcessInfo apinfo = list.get(i);
String[] pkgList = apinfo.pkgList;
if (apinfo.importance > ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
// 清理后台进程
for (int j = 0; j < pkgList.length; j++) {
String pkg = pkgList[j];
if(pkg.matches("com.android.*")){
Log.d(TAG,"not clean is system android pid pkg= " +pkg);
}else{
Log.d(TAG,"auto clean apk pkg= " + pkg);
mActivityManager.forceStopPackage(pkgList[j]);
}
}
}
}
}
}
};
网友评论