当前位置:网站首页>如何徹底强制殺死後臺無關進程?
如何徹底强制殺死後臺無關進程?
2022-07-23 21:47:00 【飛猿_SIR】
在一些低端機型或小內存的ROM中,經常會出現內存不足的情况,除了優化自身程序外,往往需要通過殺死清空一些無關的後臺進程來節省內存。但現在許多程序都做了很强的守護進程或加入了平臺白名單,常規方法都無法徹底殺死。
比如am.forceStopPackage(),或者 "adb shell killall -9 com.xxx.xxx".都是殺掉後一會又會自啟。那麼對於這種情况,改如何徹底幹掉這些討厭的家夥呢。
這裏提供一種非常規方法,通過禁用該包名來實現,不過需要注意的是,禁用包名後,對應程序進程會被清空,而且無法再啟動,應用列錶也找不到它,這就需要重新恢複該包名的可用性,這時它是不會自啟的。可通過adb命令測試:
禁用程序:adb shell pm disable com.xxx.xxx
恢複程序:adb shell pm enable com.xxx.xxx
至於代碼實現,就是通過java 發送shell指令,參考如下:
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;
}
//調用
RootCommand("pm disable com.xxx.xxx");
這樣就可以徹底幹掉後臺頑固進程,不過切記禁用後記得及時恢複該包名的可用性。
边栏推荐
- jedis 6---redisson和jedis的入门和不同
- JS object array de duplication
- Use code to set activity to transparent
- Basic knowledge of mobile phone testing
- Introduction to database system fifth edition after class exercises - Chapter 1 Introduction
- Cluster chat server: chatservice business layer
- 开源分布式链路追踪对比
- 集群聊天服务器:网络模块ChatServer
- uniapp使用canvas写环形进度条
- Kuberntes cloud native combat VI uses rook to build CEPH cluster
猜你喜欢

Description and implementation of throttling and anti shake

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

& 9 nodemon automatic restart tool

基于速度、复杂性等因素比较KernelSHAP和TreeSHAP
![[create birthday card application]](/img/56/e04a9a20e181ad7b68b0f2d1d118bc.png)
[create birthday card application]

CMake的学习

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

Synchro esp32c3 Hardware Configuration Information serial port Print Output

MySQL如何对SQL做prepare预处理(解决IN查询SQL预处理仅能查询出一条记录的问题)

LeetCode_ 376_ Wobble sequence
随机推荐
Day109. Shangyitong: integrate Nacos, hospital list, drop-down list query, hospital online function, hospital details query
Uniapp uses canvas to write a circular progress bar
Interval DP chain stone merging
ESP32 的 I2C 原理 & 应用入门
Sword finger offer Second Edition: string (simple)
MySQL如何对SQL做prepare预处理(解决IN查询SQL预处理仅能查询出一条记录的问题)
欧氏聚类(API)及其单木分割
05_ UE4 advanced_ Material UV scaling
Openlayers instance animated GIF GIF animation
Machine learning exercises -- right rate regression
Day109.尚医通:集成Nacos、医院列表、下拉列表查询、医院上线功能、医院详情查询
Union and union all of Hana SQL
Use Gaode map JS API 2.0 to load the starting and ending path tracks
寻找消失的类名
Scala programming (elementary)
138 - query case - knowledge points involved: foreach traversal & computed calculation attributes & V-for loop
CMake的学习
机器学习习题——对率回归
prime_ series_ level-1
SQL注入攻击