data.token, SERVICE_DONE_EXECUTING_ANON, 0, 0);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
} catch (Exception e) {
if (!mInstrumentation.onException(service, e)) {
throw new RuntimeException(
"Unable to create service " + data.info.name
- ": " + e.toString(), e);
}
}
}
2、其他生命周期方法
Service的其它相关生命期方法与ActivityThread.java源码中方法实现分别对应关系如下:
onStartCommand:handleServiceArgs
onBind:handleBindService
onUnbind:handleUnbindService
onDestroy:handleStopService
看完源码实现之后你会发现,上述的几个生命周期方法所操作的Service实例对象都是在方法handleCreateService中所创建的对象。因此对于Service的插件化实现我们只需要拦截方法handleCreateService就足以。
三、Service插件化的实现
1、实现步骤
有了上述源码的理解分析以及上一篇所实现