0

I want to implement a service which should be running like standard system service on boot up, this service should not be kill-able and should be able to perform action on receiving notification from another process.

Can anyone help me which is the best methodology (AIDL) to create such service,if any example for reference ?

3 Answers 3

1

You can't do this unless you are creating your own system ROM.

If creating your own ROM, you can start by modifying the AndroidManifest of the apk containing your service. You need to add an attribute to your manifest node: android:sharedUserId="android.uid.system". That will cause your APK to hold the system ID (which requires the APK to be signed with your platform signing key -- this is why you need to be creating your own system ROM.

That will allow your application to be considered special by the system, and (at least on 4.x, I haven't tested on older Android versions) your application will be auto-started. The application being auto-started doesn't mean much on its own though; either you need to implement a BOOT_COMPLETED receiver as @febinkk suggests, or you can provide a custom Application override (by adding the attribute android:name="your.package.ApplicationSuperClass" to your application node in your AndroidManifest.xml). In your application super class, you can overload onCreate() and have it start your service or whatever else is required.

Additionally, as a system application, I believe (though have not fully tested) you will not be able to be killed through normal means.

Sign up to request clarification or add additional context in comments.

3 Comments

Yes I will create my own ROM no issues on that, but I want to know if there is any example which does this way?
I've expanded my answer to take this into account.
Is there any standard Android service which is written in way which I can clone to develop my own service?
0

You are not able to create non-killable, immune service without creating your own ROM

1 Comment

Yes I will create my own ROM no issues on that, but I want to know if there is any example which does this way?
0

You could register a BroadcastReciever with filter for android.intent.action.BOOT_COMPLETED for your service and after starting call startForeground(). This may not be what exactly you were looking, but this is probably the only thing that comes near, if you don't want to create ROM.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.