开发者

ServiceLeakedException while using services android

开发者 https://www.devze.com 2023-03-21 06:56 出处:网络
I had a Activity That is binding with 开发者_JAVA百科a service and is able to communicate withthe service as well.

I had a Activity That is binding with 开发者_JAVA百科a service and is able to communicate with the service as well.

 bindService(intent,serviceConnection,Context.BIND_AUTO_CREATE);

My Code is running well. But when i finishes my activity A ServiceLeakedException is thrown, but that is there in the log only. no such exception is their on to the visuals and is working fine.

Should i ignore this or how to handle this properly.

Thanks Amandeep


Thats easy to trick down.

You are forgetting to unbind from the service.

Just override the onDestroy delegate of your Activity and in that unbind from the service. Do something like this

 protected void onDestroy()
  {
     unbind(serviceConnection);
     super.onDestroy()
  }

Hope it helps :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号