日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

服务 进程守护 MarsDaemon 简介

發布時間:2024/4/17 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 服务 进程守护 MarsDaemon 简介 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

MarsDaemon 基本功能

https://github.com/Marswin/MarsDaemonIt 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 23support 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 simplelymy 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"/>
  • 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.
  • @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);
  • }

  • 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!
  • private DaemonClient mDaemonClient;
  • @Override
  • protected void attachBaseContext(Context base) {
  • ? ? super.attachBaseContext(base);
  • ? ? mDaemonClient = new DaemonClient(createDaemonConfigurations());
  • ? ? mDaemonClient.onAttachBaseContext(base);
  • }

  • 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地址:https://github.com/Marswin/MarsDaemon
    原理分析:

    Android 進程常駐(0)----MarsDaemon使用說明

    Android 進程常駐(1)----開篇

    Android 進程常駐(2)----細數利用android系統機制的保活手段

    Android 進程常駐(3)----native保活5.0以下方案推演過程以及代碼詳述

    Android 進程常駐(4)----native保活5.0以上方案推演過程以及代碼詳述

    Android 進程常駐(5)----開機廣播的簡單守護以及總結

    總結

    以上是生活随笔為你收集整理的服务 进程守护 MarsDaemon 简介的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。