当前位置:网站首页>如何徹底强制殺死後臺無關進程?
如何徹底强制殺死後臺無關進程?
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");
這樣就可以徹底幹掉後臺頑固進程,不過切記禁用後記得及時恢複該包名的可用性。
边栏推荐
- Providers and consumers tags in zfoo
- At 12 o'clock on July 23, 2022, the deviation from the top of the line of love life hour appeared, maintaining a downward trend and waiting for the rebound signal.
- SQL injection attack
- Programmer growth Article 26: how to hold a good daily morning meeting?
- Basic syntax of MySQL DDL and DML and DQL
- -2021 sorting and sharing of the latest required papers related to comparative learning
- ESP32 的 I2C 原理 & 应用入门
- How to implement desktop lyrics in pyqt
- Redis常用命令对应到Redisson对象操作
- Serveur de chat de Cluster: conception de la table de base de données
猜你喜欢

CMake的学习

Compare kernelshap and treeshap based on speed, complexity and other factors

基于速度、复杂性等因素比较KernelSHAP和TreeSHAP

At 12 o'clock on July 23, 2022, the deviation from the top of the line of love life hour appeared, maintaining a downward trend and waiting for the rebound signal.
![[complex overloaded operator]](/img/ff/aafaa9471a1bd6ef57f6a619449e80.png)
[complex overloaded operator]

Day109.尚医通:集成Nacos、医院列表、下拉列表查询、医院上线功能、医院详情查询

query中的customer exit客户出口变量

Openlayers instances advanced mapbox vector tiles advanced mapbox vector maps

Customer exit variable in query

Apprentissage Lambda (utilisation du comparateur après tri, regroupement après collecte avec collectors.groupingby)
随机推荐
Unity - 3D mathematics -vector3
MySQL数据库索引
Protocol buffers 的问题和滥用
Euclidean clustering (API) and its single tree segmentation
开源分布式链路追踪对比
DBSCAN点云聚类
实时监控Mysql数据库变化_进行数据同步_了解Canal_---Canal工作笔记001
[arXiv] notes on uploading papers for the first time
Cesium core class viewer viewer details
记第一次挖洞交洞历程
Detailed explanation of cesium events (mouse events, camera events, keyboard events, scene trigger events)
Serveur de chat de Cluster: conception de la table de base de données
Chapter 2 Regression
Day109.尚医通:集成Nacos、医院列表、下拉列表查询、医院上线功能、医院详情查询
[hiflow] Tencent cloud's new generation of automation assistant, which I used to complete the enterprise epidemic prompt (no code)
U++ 学习笔记 控制物体Scale
Deep learning - NLP classic papers, courses, papers and other resources sorting and sharing
Machine learning exercises -- right rate regression
Redis常用命令对应到Redisson对象操作
博客总排名为918