After your clarification regarding the killing:
You probably want to run your Service
in a different process than your Application
, which you can achieve by such a declaration in your manifest:
<service
android:name=".ServiceClassName"
android:process=":yourappname_background" >
...
Use the same android:process
attribute for any receiver
declarations in your manifest.
If you only want to receive events which can be declared in the manifest, you can consider using an IntentService
, which will almost never be visible to the user due to its short activity timespan. However, if you need to listen to events which can only be received when you register receivers programmatically (in which case, obviously, the receiver
clause in the manifest makes no sense) then you cannot do anything against a user (or one of the "smart app killers") killing your service. The advantage, still, would be that users hopefully understand that your app can be killed, while your Service
can't (if they want it to do something).
Additionally, you can bring your Service to the foreground.