Android Activity onDestroy()中unBindService,提示Service not registered
Android Activity onCreate() 中 bindService,onDestroy()中unBindService,提示AndroidRuntime: Caused by: java.lang.IllegalArgumentException: Service not registered
已经使用了一个boolean flag 标记是否成功执行bindService了。
在onCreate()里,用的flag = bindService(intent,connection,BIND_AUTO_CREATE);来接bindService的结果了。
在onDestroy()里,用
if(true == flag)
{
unbindService(connection);
flag = false;
}
但是有一次在执行onDestroy 的时候,还是报了AndroidRuntime: Caused by: java.lang.IllegalArgumentException: Service not registered
请问大佬这是怎么回事?
有没有可能是bindService时候返回true,但实际并未成功? 或者connection取的不对...