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. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) F - Uniformly Branched Trees 无根树->有根树+dp

    F - Uniformly Branched Trees #include<bits/stdc++.h> #define LL long long #define fi first #de ...

  2. php大图

    原文地址:https://laravel-china.org/articles/9450/php-fpm-vs-swoole

  3. JAVA编程思想读书笔记(一)--面向对象

    第二章 一切都是对象 No1: 程序运行时,我们最好对数据保存到什么地方做到心中有数.特别要注意的是内存的分配.有六个地方都可以保存数据: (1) 寄存器.这是最快的保存区域,因为它位于和其他所有保存 ...

  4. Python之路【第三篇】:文件操作

    一.文件操作步骤 打开文件,得到文件句柄并赋值给一个变量 通过句柄对文件进行操作 关闭文件 歌名:<大火> 演唱:李佳薇 作词:姚若龙 作曲:马奕强 歌词: 有座巨大的停了的时钟 倾倒在赶 ...

  5. python配置libsvm

    转载博文:win10(64-bit) + python3.6.0(64-bit) 配置libsvm-3.22 https://blog.csdn.net/weixin_35884839/article ...

  6. Eclipse项目红色叹号解决方法

    情况:就是项目出现红色感叹号 解决方法: 对准项目右键选择Build Path → configure build path 点击eclipse项目的configure build path后,在弹出 ...

  7. FastReport.Net使用:[26]数字格式

    1.数据包含固定格式的小数,自由格式的小数,以及字符串格式等四列数据.包含3行数据(1.2,1.23,1.234). 以下为Access数据视图和FastReport.Net报表设计器中的数据视图. ...

  8. LruCache 原理

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha LruCache 使用一个 链表式的哈希图LinkedHashMap 简单的实现 内存的 ...

  9. BZOJ1552/3506 [Cerc2007]robotic sort

    Splay 与之前不同的是如果你仅仅是翻转左右区间的话可以在find里面做因为对他有影响的子树在做之前一定在他的上面从上到下搜索的过程可以把rever做了. 但这道题要求我们输出转换之前的,因此不能保 ...

  10. 「BZOJ 2534」 L - gap字符串

    「BZOJ 2534」 L - gap字符串 题目描述 有一种形如 \(uv u\) 形式的字符串,其中 \(u\) 是非空字符串,且 \(v\) 的长度正好为 \(L\), 那么称这个字符串为 \( ...