开发者

ServiceLeakedException while using services android

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜