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

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.
  1. <service android:name=".Service1" android:process=":process1"/>
  2. <receiver android:name=".Receiver1" android:process=":process1"/>
  3. <service android:name=".Service2" android:process=":process2"/>
  4. <receiver android:name=".Receiver2" android:process=":process2"/>

Service1 is the Service which you want to be undead, you can do somethings in it.

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.

  1. @Override
  2. protected DaemonConfigurations getDaemonConfigurations() {
  3.     DaemonConfigurations.DaemonConfiguration configuration1 = new DaemonConfigurations.DaemonConfiguration("com.marswin89.marsdaemon.demo:process1", Service1.class.getCanonicalName(), Receiver1.class.getCanonicalName());
  4.     DaemonConfigurations.DaemonConfiguration configuration2 = new DaemonConfigurations.DaemonConfiguration("com.marswin89.marsdaemon.demo:process2", Service2.class.getCanonicalName(), Receiver2.class.getCanonicalName());
  5.     DaemonConfigurations.DaemonListener listener = new MyDaemonListener();
  6.     //return new DaemonConfigurations(configuration1, configuration2);//listener can be null
  7.     return new DaemonConfigurations(configuration1, configuration2, listener);
  8. }

if you want to override attachBaseContext you will find it had been defined final by me. you can override attachBaseContextByDaemon instead it.


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!

  1. private DaemonClient mDaemonClient;
  2. @Override
  3. protected void attachBaseContext(Context base) {
  4.     super.attachBaseContext(base);
  5.     mDaemonClient = new DaemonClient(createDaemonConfigurations());
  6.     mDaemonClient.onAttachBaseContext(base);
  7. }

see more details in MyApplication2 in DemoMarsdaemon

STEP3

Launch the Service once, and try to kill it.

相关分析文章

这是一个轻量级的库,配置几行代码,就可以实现在Android上实现进程常驻,也就是在系统强杀下,以及360获取root权限下,clean master获取root权限下都无法杀死进程
支持系统2.3到6.0
支持大部分设备,包括三星,华为,oppo,nexus,魅族等等
可以简单对开机广播进行保护

github地址:

原理分析:

服务 进程守护 MarsDaemon 简介的更多相关文章

  1. Linux控制服务和守护进程

    目录 控制服务和守护进程 1.systemd 1.1.systemd简介 1.2.systemd的新特性 1.3.systemd的核心概念Unit 2.使用systemctl管理服务 控制服务和守护进 ...

  2. Supervisor 为服务创建守护进程

    今天需要再服务上部署一个.net 方面的项目:当时开启服务的命令只能在前台执行:使用nohub CMD &等放在后台开启服务都会宕机:所以搜寻了Supervisor 这个解决办法,为服务创建守 ...

  3. Android 保持Service不被Kill掉的方法--双Service守护 && Android实现双进程守护

    本文分为两个部分,第一部分为双Service守护,第二部分为双进程守护 第一部分: 一.Service简介:Java.lang.Object ↳Android.content.Context  ↳an ...

  4. 保持Service不被Kill掉的方法--双Service守护 && Android实现双进程守护

    本文分为两个部分,第一部分为双Service守护,第二部分为双进程守护 第一部分: 一.Service简介:Java.lang.Object ↳Android.content.Context  ↳an ...

  5. Python Twisted系列教程16:Twisted 进程守护

    作者:dave@http://krondo.com/twisted-daemonologie/  译者: Cheng Luo 你可以从”第一部分 Twist理论基础“开始阅读:也可以从”Twisted ...

  6. systemd - CentOS 7进程守护&监控

    需求: 运行环境为CentOS 7系统,我们开发了一个程序,需要在开机时启动它,当程序进程crash或者开机之后,守护进程立即拉起进程. 解决方案: 使用CentOS 7中的init进程systemd ...

  7. Android实现双进程守护 (转)

    做过android开发的人应该都知道应用会在系统资源匮乏的情况下被系统杀死!当后台的应用被系统回收之后,如何重新恢复它呢?网上对此问题有很多的讨论.这里先总结一下网上流传的各种解决方案,看看这些办法是 ...

  8. Android NDK(C++) 双进程守护

    双进程守护如果从进程管理器观察会发现新浪微博.支付宝和QQ等都有两个以上相关进程,其中一个就是守护进程,由此可以猜到这些商业级的软件都采用了双进程守护的办法. 什么是双进程守护呢?顾名思义就是两个进程 ...

  9. 安全之路 —— C++实现进程守护

    简介 所谓进程守护,就是A进程为了保护自己不被结束,创建了一个守护线程来保护自己,一旦被结束进程,便重新启动.进程守护的方法多被应用于恶意软件,是一个保护自己进程的一个简单方式,在ring3下即可轻松 ...

随机推荐

  1. Error: Exception was raised when calling event-notify Vuser function in extension parameng.dll: System Exceptions: EXCEPTION_ACCESS_VIOLATION

    解决方法:在C 盘新建一个TEMP目录,把环境变量TMP,TEMP的值设置成环境变量,重启计算机

  2. shell-grep命令详解(转)

    (转自http://blog.csdn.net/onlyou930/article/details/6582409) 用‘grep’搜索文本文件如果您要在几个文本文件中查找一字符串,可以使用‘grep ...

  3. ref:spring-data-XMLBean XXE复现分析

    ref:https://blog.spoock.com/2018/05/16/cve-2018-1259/ 漏洞信息 看pivotal发布的漏洞信息如下 通过发布的漏洞信息可以知道,漏洞组件是在XML ...

  4. Beaglebone Black开发板安装驱动

    Beaglebone Black开发板安装驱动 Beaglebone Black开发板安装驱动,在使用Beaglebone Black开发板子做任何事情之前首先需要安装驱动.下面的内容就了展示在Win ...

  5. JavaScript with JSONPath

    <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>JavaScript JSO ...

  6. HDU 1213(并查集)

    How Many Tables Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  7. NOIP2018提高组题解

    D1T1:铺设道路 回忆NOIP2013D2T1 积木大赛,发现这两题唯一的区别就是一个是造山一个是填坑,而把填坑的操作反序就是造山,所以可以直接使用那道题的方法. 具体方法是,从左到右每次考虑新的一 ...

  8. finish/onDestroy/System.exit()的区别

    Activity.finish():Call this when your activity is done and should be closed. 在你的activity动作完成的时候,或者Ac ...

  9. SCOJ 4429: frog's dice 最大流

    4429: frog's dice 题目连接: http://acm.scu.edu.cn/soj/problem.action?id=4429 Description frog has many d ...

  10. 51nod 1225 余数之和 数论

    1225 余数之和 题目连接: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1225 Description F(n) ...