mContext.getUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
源码解释: 让系统立即终止与给定程序包关联的所有后台进程。这与内核杀死那些进程以回收内存的过程相同。系统会在将来根据需要重新启动这些过程。
[](()后台自动清理实现
通过自定义一个服务或者悬浮窗在后台运行,获取当前运行前台运行的包名,用一个集合recentList进行存储,当数量达到多少时执行清理任务
List recentList = new ArrayList<>(10); //后台包名缓存列表
/**
-
执行桌面后台启动任务清理
-
@author lhw
*/
private synchronized void clearRecentTask() {
Log.w(TAG, “clearRecnetTask recentList==” + recentList.toString());
final ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
long beforeMem = getAvailMemory(am);
Log.w(TAG, "-----------before memory info : " + beforeMem);
if (recentList != null && r