Registering SERVICE into ServiceManger of AOSP

46 views
Skip to first unread message

SSI

unread,
Sep 24, 2014, 3:40:43 AM9/24/14
to android...@googlegroups.com
Hi,

  In my project I have created Service (Customized service)class to listen events from JNI/HAL. This service I registered in a SystemService.java file of AOSP. So my service is getting add into ServiceManager.java like below

  try {
                 Slog.i(TAG, "MyService");
                 ServiceManager.addService("xxx", new MyService(context));
        }catch (Throwable e){
                   reportWtf("starting MyService_service", e);
             }

  Now MyService will call up when device is power on. But I want to start a service when my app is opened from UI. I.e I want to add  MyService.java into a ServiceManger by opening app from UI. How to do in AOSP.

   Where I have to use the above code instead of SystemServer.java

Thanks

Narrator

unread,
Sep 24, 2014, 10:49:15 AM9/24/14
to android...@googlegroups.com


I guess you do like this , Create your service in init script and set some property in your app UI(using setProperty function) and wait for that property in init script to start the service.
Creating service.
service myservice system/bin/myservice 
disabled 

on property:custom_property=1 
  start  myservice 

on property:custom_property=0
  stop myservice 

while closing the app.

I'm not sure but just my thought.


Narrator 

Regard
Reply all
Reply to author
Forward
0 new messages