I'm searching the Internet for a several days with no result. So, I decided to ask the community to shed some light on this.
I have an application written in C++ that I compiled for Android OS. The app can also be run as daemon (by specifying --daemon option). When it's run as the regular executable it works fine, but when I try it to start as daemon it disappears after the fork() is performed I see it in logcat.
The questions are: 1. Whether it is possible to adapt Unix/Linux daemon code to work on Android? If yes how? 2. How to start it on boot? I suppose by init.rc, but how to edit it persistently? 3. If no. Is there any android specific approach to solve the task?
Please feel free to post links you think can be useful.
Yes, this can be done on the platform level. Under the hood, Android is almost yet another Linux system, and it runs Linux-style services. You can pick up an existing service in AOSP, like SurfaceFlinger, and add your functionality to it. Or you can develop your own service from ground up. In any case, you start with building your own AOSP fork.
Here is a nice tutorial: https://devarea.com/aosp-adding-a-native-daemon
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With