官方解释
/**
* Called when all clients have disconnected from a particular interface
* published by the service. The default implementation does nothing and
* returns false.
*
* @param intent The Intent that was used to bind to this service,
* as given to {@link android.content.Context#bindService
* Context.bindService}. Note that any extras that were included with
* the Intent at that point will not be seen here.
*
* @return Return true if you would like to have the service’s
* {@link #onRebind} method later called when new clients bind to it.
*/
public boolean onUnbind(Intent intent)
问题
- 明明说得当所有客户端都已从特定接口断开连接时调用onUnbind() , 但是还有client绑定着Service,确执行了onUnbind
解决方案
- 统一 bindService() 方案
···
Intent intent = new Intent();
intent.setPackage(“com.smaple.demo