Android Process Resident (0)----Marsdaemon instructions for use

Source: Internet
Author: User

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

This is a lightweight library, configure a few lines of code, you can implement on Android to achieve the process of permanent, that is, under the system strong kill, as well as 360 get root, clean master can not kill process under root permission

Support System 2.3 to 6.0

Support for most devices, including Samsung, Huawei, Oppo,nexus, Meizu, etc.

Can simply protect the power-on broadcast


GitHub Address:

Https://github.com/Marswin/MarsDaemon

Principle Analysis:

Android Process Resident (0)----Marsdaemon instructions for use

Android Process Resident (1)----opening

Android Process resident (2)----count the keepalive means of using the Android system mechanism

Android Process resident (3)----Native KeepAlive 5.0 The following scenario deduction process and code details

Android Process Resident (4)----native 5.0 above program deduction process and code details

Android Process Resident (5) Simple guardian and summary of----start-up broadcast



Body:

Marsdaemon configuration requires three steps:


1. Make clear that you need a permanent process service, create a receiver with the process, and then create a service and a receiver in another process, and write it in manifest. process names can be customized

See/marsdaemon/demomarsdaemon/src/main/androidmanifest.xml


Service1 is a service that requires a resident process with business logic in the application, and the other three components are created in addition, so don't do anything, it's empty implementation.


2. Use your application to inherit the Daemonapplication, and then return a configuration in the callback method Getdaemonconfigurations, passing in the process name, service class name, receiver class name just registered.

Code/marsdaemon/demomarsdaemon/src/main/java/com/marswin89/marsdaemon/demo/myapplication1



At this point, if you want to make a Attachbasecontext method in your application, you find that he has been written as final, because we need to a footrace, so we must ensure that the process enters the first load Marsdaemon, If you want to do something in Attchbasecontext, you can make a carbon Attachbasecontextbydaemon method.


If your application has inherited other application classes, then you can refer to Appliation2, initialize a attachbasecontext when application daemonclient, And then call his onattachbasecontext can also be implemented, of course, he also needs a configuration to tell him we just had a message in the Menifest

Code Code/MARSDAEMON/DEMOMARSDAEMON/SRC/MAIN/JAVA/COM/MARSWIN89/MARSDAEMON/DEMO/MYAPPLICATION2




3, the third step is to try to kill the process


Android Process Resident (0)----Marsdaemon instructions for use

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.