How to Add our own System Service in Android Framework?

前端 未结 4 912
抹茶落季
抹茶落季 2021-02-05 15:08

I am new to android and i have been analyzing the android source code to understand how the System services are implemented. My Question is am I able to create my own System Se

4条回答
  •  北海茫月
    2021-02-05 15:41

    Follow the below steps for writing your own System Service in android framework.

    1. Write your Own Service/Manager with API's exposed by inheriting the stub.
    2. Create an aidl file for your service to expose & include in build.
    3. Add your service in System Server, you service will start along with all core services.
    4. Register your service context in context impl file.
    5. Use your service in application by calling getSystemService(Context of your service)

    PS: if your service get some fatal exception, device will soft reboot, as your service is running under system service.

提交回复
热议问题