android Service的个人理解
1.个人对onBind(Intent intent)的理解
多个client可以同时连接到同一个service,但是只有第一次连接的时候会调用onBind(),其他的client调用BindService时,不再调用onBind(),只会返回IBinder,onServiceConnected仍然会被多次调用。当所有的client unbind,service 将会被destroyed。
Multiple clients can connect to the service at once. However, the system calls your service's onBind() method to retrieve the IBinder only when the first client binds. The system then delivers the same IBinder to any additional clients that bind, without calling onBind() again.http://developer.android.com/guide/components/bound-services.html Multiple components can bind to the service at once, but when all of them unbind, the service is destroyed.
参考:http://stackoverflow.com/questions/3069409/illegalargumentexception-service-not-registered
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步