服务 进程守护 MarsDaemon 简介
MarsDaemon 基本功能
It is a lite library, you can make your project depend it easily, and your project will be UNDEAD不会被杀死.
support to keep alive from Android_API 9 to Android_API 23
support to keep alive in most of devices各种机型(contains Sumsung\Huawei\Meizu\Mi\Nexus..)
support to keep alive in FORCE_CLOSE强制关闭 from SystemSettings系统设置 and MEMORY_CLEAN内存清理 from third-part第三方清理工具 apps (such like CleanMaster\360 and so on)
support to keep BOOT_RECEIVER完美自启动 work well simplely
my Blog in Chinese here: http://blog.csdn.net/marswin89/article/details/50917098
Version 1.0
Installation 使用步骤
STEP1
make your project depend on LibMarsdaemon, and regist 2 Service and 2 BroadcastReceiver in your manifests in 2 different process.
<service android:name=".Service1" android:process=":process1"/>
<receiver android:name=".Receiver1" android:process=":process1"/>
<service android:name=".Service2" android:process=":process2"/>
<receiver android:name=".Receiver2" android:process=":process2"/>
But the others is used by Marsdaemon, so DONNOT do anything inside.
STEP2
make your application extends DaemonApplication and override the method getDaemonConfigurations(). Return back the confugirations.
@Override
protected DaemonConfigurations getDaemonConfigurations() {
DaemonConfigurations.DaemonConfiguration configuration1 = new DaemonConfigurations.DaemonConfiguration("com.marswin89.marsdaemon.demo:process1", Service1.class.getCanonicalName(), Receiver1.class.getCanonicalName());
DaemonConfigurations.DaemonConfiguration configuration2 = new DaemonConfigurations.DaemonConfiguration("com.marswin89.marsdaemon.demo:process2", Service2.class.getCanonicalName(), Receiver2.class.getCanonicalName());
DaemonConfigurations.DaemonListener listener = new MyDaemonListener();
//return new DaemonConfigurations(configuration1, configuration2);//listener can be null
return new DaemonConfigurations(configuration1, configuration2, listener);
}
see more details in MyApplication1 in Demo
if your application has extends another application, you should create a DaemonClient and perfrom it in attachBaseContext(), DONOT forget perform super.attachBaseContext() before!
private DaemonClient mDaemonClient;
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
mDaemonClient = new DaemonClient(createDaemonConfigurations());
mDaemonClient.onAttachBaseContext(base);
}
STEP3
Launch the Service once, and try to kill it.
相关分析文章
这是一个轻量级的库,配置几行代码,就可以实现在Android上实现进程常驻,也就是在系统强杀下,以及360获取root权限下,clean master获取root权限下都无法杀死进程
支持系统2.3到6.0
支持大部分设备,包括三星,华为,oppo,nexus,魅族等等
可以简单对开机广播进行保护
github地址:
原理分析:
本文来自博客园,作者:白乾涛,转载请注明原文链接:https://www.cnblogs.com/baiqiantao/p/6375739.html
分类:
03 可能乱码的文章
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现