今天看到service的例子时候用serviceConnection的onserviceConnected()方法就想着和直接startService()方法有啥区别
<strong>startService(Intent intent)</strong>
<span style="font-size:12px;">bindService (Intent service, ServiceConnection conn, int flags)</span>
<span style="font-size:12px;">bindService (Intent service, ServiceConnection conn, int flags)</span>
This function will throw SecurityException if you do not have permission to bind to the given service.
Note: this method can not be called from an BroadcastReceiver component. A pattern you can use to communicate from an BroadcastReceiver to a Service is to call startService(Intent) with the arguments containing the command to be sent, with the service calling its stopSelf(int) method when done executing that command. See the API demo App/Service/Service Start Arguments Controller for an illustration of this. It is okay, however, to use this method from an BroadcastReceiver that has been registered with registerReceiver(BroadcastReceiver, IntentFilter), since the lifetime of this BroadcastReceiver is tied to another object (the one that registered it).
这个方法不能被广播接收组件调用。
结论:
startService()是服务和intent分开的,从intent跳转到后面的service的。
serviceConnection()是绑定某个intent的。