1

I am trying to have a service (running all the time). This service would also have some C/C++ JNI code to access(get info) few other components in the platform and also need to access HAL. We also need to store data (in some kind of storage DB, file, etc). We have some other app need access to this data from this Service. In symbolic way here is what I am aiming for

Android App -> System Service -> JNI (native) library -> HAL/DeviceDriver.

My Questions:

  1. Can we do this as a regular Android Service (the way all downloadable app/services are written) or it must be included in System Services?
  2. How can I make sure my service is alive all the time and starts on boot-up or platform up?
  3. If it has to be in System services how to do that? Can downloadable apps access this System service?

1 Answer 1

1

1 - If you just need to acess the DATA generated by this service, you can do your service as a Android Service

2 - You need to register a BOOT_RECEIVER broadcast in your maifest, then in the onReceive of your Broadcast, you start your service, something like this:

Manifest:

     <receiver
        android:name="YOUR.PACKAGE.BootBroadcast"
        android:enabled="true"
        android:exported="true">
       <intent-filter>
         <action android:name="android.intent.action.BOOT_COMPLETED" />
       </intent-filter>
     </receiver>

 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

BootBroadcast:

public class BootBroadcast extends BroadcastReceiver {


    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
            // start your service

        }
    }


}

3 - Don´t know the answer

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

5 Comments

Hi Rodrigo Appreciate you response. Yes I want data from this service but 1) The service need to access HAL and other Android components. 2) It should be alive all the time. 3) No one should be able to uninstall it.
1) A Service behavior is similar to the Activity behavior, if you can do your stuff ( like access HAL and other android components) in some Activity, you could do this in Service 2) Just implement this ( stackoverflow.com/questions/9109372/… ) and your service will run forever! 3) If you want to no one uninstall your service, you need to make your app as a system app ( just do litte search to this, it´s not complicated if you have root access )
Hi Rodrigo Your comments clarified few of my points. I have access to the full platform code. I am looking from the design perspective (regular downloadable vs System level ). Could you please let me know how to upvote?
I was refering to my answer in stackOverflow
@Hi Rodrigo I know that was for your answer in this thread and to accept it. But I couldn't see the option to accept/upvote that.

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.