1、 手机ROM定制商: 添加service到SystemService
Service端实现: class CTestService extends ITest.Stub .
ServiceManager.addService("testinterface", this);
// 需要增加到相应的位置,确保系统启动时就供调用。
客户端:通过aidl调用远程service
使用 context.getSystemService 方法获取 ITest,
2、APK开发者调用一个普通的Service(其他APK提供的,或本APK提供的同进程或不同进程的):
定义一个Service的派生类:
private ITestService.Stub binder = new ITestService.Stub()
{ 在这个匿名类中实现AIDL的函数列表};
public IBinder onBind(Intent intent)
{ ... return binder}