Android Marsdaemon implementation process and service residency

Source: Internet
Author: User

A period of time ago. After discussing how to keep the service in memory without being killed, the final conclusion is to use JNI to implement the daemon, but it must be said that in the absence of changes to the system source code, it is very difficult to really achieve the killing service. Now in addition to the white list of ways. Also seems to have not found an app can do it regardless of how it can be self-initiated restart ...

Recently found on GitHub a more interesting lightweight library: Marsdaemon, to carry out some simple configuration, can be real today on the Android implementation of the process of permanent, in the system to kill or 360 security defender and other software, can not really kill the process.

Of course. Try it on Huawei's pad. Manually stop the application in the program management, do not voluntarily restart. But after some security guard's software kill the process, still can be able to proactively restart.

Let's not say this can really kill undead service, can do this step has been applied to most of the needs of the app, so it is worth a look, interested in children's shoes can also go to the bottom of the implementation process ~

Just think about how to implement the daemon using JNI: http://blog.csdn.net/yyh352091626/article/details/50542554

In fact, the core idea is almost identical. is the Guardian process. The library supports the Android system for 2.3~6.0, which almost applies to all Android phones. Including Samsung, Huawei, Meizu, Millet, Lenovo and so on.

Marsdaemon Library demo:http://download.csdn.net/detail/yyh352091626/9468312

The detailed implementation process is as follows:

First, configure the service in manifest. and create a receiver with the process, and then create a service and a receiver in another process. Process 1 is a process that needs to be permanent. Process 2 can be emptied.

Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity /center "height=" >


Second, let our own application inherit daemonapplication, and rewrite getdaemonconfigurations to carry out the related configuration.

Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity /center "height=" >

Third, if you do not want to inherit daemonapplication and directly inherit the system's application or their own definition application words, in the OnCreate to initialize. For example, the following:


Four, the use of security guard and other cleanup software kill process. The discovery process voluntarily restarts itself.




Android Marsdaemon implementation process and service residency

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.