当前位置:网站首页>How to completely force the killing of background unrelated processes?
How to completely force the killing of background unrelated processes?
2022-07-23 21:47:00 【Flying ape_ SIR】
In some low-end models or small memory ROM in , Memory shortage often occurs , In addition to optimizing their own programs , It is often necessary to save memory by killing and emptying some irrelevant background processes . But now many programs have made strong daemons or joined the platform white list , Conventional methods cannot completely kill .
such as am.forceStopPackage(), perhaps "adb shell killall -9 com.xxx.xxx". After killing, it will start again . So in this case , How to completely kill these annoying guys .
Here is an unconventional method , By disabling the package name , But here's the thing , After disabling the package name , The corresponding program process will be emptied , And it cannot be started again , The app list can't find it , This requires restoring the availability of the package name , At this time, it will not start itself . It can be done by adb Command test :
Disable program :adb shell pm disable com.xxx.xxx
Recovery procedure :adb shell pm enable com.xxx.xxx
As for the code implementation , It is through java send out shell Instructions , Refer to the following :
public static boolean RootCommand(String command)
{
Process process = null;
DataOutputStream os = null;
try {
process = Runtime.getRuntime().exec("sh");
os = new DataOutputStream(process.getOutputStream());
os.writeBytes(command + "\n");
os.writeBytes("exit\n");
os.flush();
process.waitFor();
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
try {
if (os != null) {
os.close();
}
process.destroy();
} catch (Exception e) {
}
}
return true;
}
// call
RootCommand("pm disable com.xxx.xxx");
In this way, we can completely kill the stubborn process in the background , However, remember to restore the availability of the package name in time after disabling .
边栏推荐
猜你喜欢

Serveur de chat de Cluster: conception de la table de base de données

DBSCAN point cloud clustering

Euclidean clustering (API) and its single tree segmentation

NLP field history most complete must read classic papers classification, sorting and sharing (with Chinese analysis)

Cookie 和 Session

U++ 学习笔记 控制物体Scale

query中的customer exit客户出口变量

集群聊天服务器为什么引入负载均衡器

Golang invalid argument to intn报错的解决

PCL出错:error C2589“(“:“::“右边的非法标记)
随机推荐
PCL error: error c2589 "(": "::" illegal mark on the right)
集群聊天服务器:chatService业务层
U++学习笔记 基础人物轴绑定及映射绑定
Postgraduate entrance examination | advanced mathematics Chapter4 indefinite integral
给定一个以数字组成的数组,实现输出id为数字,并且从小到大排序的name
U++ learning notes tsubclassof()
[mathematical modeling summer training] location of distribution center
Complete set of official openlayers instances
Cesium keyboard and mouse control camera roaming (source code + principle explanation)
【HiFlow】腾讯云新一代自动化助手,我用它完成了企业疫情提示(无代码)
Use code to set activity to transparent
H264 encoding parameters
Openlayers instance accessible map accessible map
集群聊天服务器:Model数据层的框架设计和数据库代码的封装
Chapter 2 Regression
阿里onedate分层思想
Still have 1 requests outstanding when connection from slaveX/X.X.X.X:33202 is closed
Looking for the missing class name
Kuberntes cloud native combat VI uses rook to build CEPH cluster
开源分布式链路追踪对比