Android服务泄漏

时间:2013-07-18 05:07:15

标签: android web-services android-asynctask android-service

我的应用程序运行成功,但如果我把我的应用程序理想状态保持3到5分钟,它显示您的应用程序停止了,在我的应用程序中我使用了服务,Asynctask概念,您可以观察下面的数据

07-18 05:00:12.779: W/ActivityManager(277): Unbind failed: could not find connection for android.os.BinderProxy@41013b90
07-18 05:00:12.779: E/ActivityThread(692): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d48ec8 that was originally bound here
07-18 05:00:12.779: E/ActivityThread(692): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d48ec8 that was originally bound here
07-18 05:00:12.779: E/ActivityThread(692):  at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
07-18 05:00:12.779: E/ActivityThread(692):  at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
07-18 05:00:12.779: E/ActivityThread(692):  at android.app.ContextImpl.bindService(ContextImpl.java:1418)
07-18 05:00:12.779: E/ActivityThread(692):  at android.app.ContextImpl.bindService(ContextImpl.java:1407)
07-18 05:00:12.779: E/ActivityThread(692):  at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
07-18 05:00:12.779: E/ActivityThread(692):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
07-18 05:00:12.779: E/ActivityThread(692):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
07-18 05:00:12.779: E/ActivityThread(692):  at com.android.emailcommon.service.AccountServiceProxy.getDeviceId(AccountServiceProxy.java:116)
07-18 05:00:12.779: E/ActivityThread(692):  at com.android.exchange.ExchangeService.getDeviceId(ExchangeService.java:1249)
07-18 05:00:12.779: E/ActivityThread(692):  at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1856)
07-18 05:00:12.779: E/ActivityThread(692):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
07-18 05:00:12.779: E/ActivityThread(692):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
07-18 05:00:12.779: E/ActivityThread(692):  at android.os.AsyncTask$2.call(AsyncTask.java:287)
07-18 05:00:12.779: E/ActivityThread(692):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
07-18 05:00:12.779: E/ActivityThread(692):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
07-18 05:00:12.779: E/ActivityThread(692):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
07-18 05:00:12.779: E/ActivityThread(692):  at java.lang.Thread.run(Thread.java:856)
07-18 05:00:12.870: E/StrictMode(692): null
07-18 05:00:12.870: E/StrictMode(692): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d48ec8 that was originally bound here
07-18 05:00:12.870: E/StrictMode(692):  at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
07-18 05:00:12.870: E/StrictMode(692):  at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
07-18 05:00:12.870: E/StrictMode(692):  at android.app.ContextImpl.bindService(ContextImpl.java:1418)
07-18 05:00:12.870: E/StrictMode(692):  at android.app.ContextImpl.bindService(ContextImpl.java:1407)
07-18 05:00:12.870: E/StrictMode(692):  at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
07-18 05:00:12.870: E/StrictMode(692):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
07-18 05:00:12.870: E/StrictMode(692):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
07-18 05:00:12.870: E/StrictMode(692):  at com.android.emailcommon.service.AccountServiceProxy.getDeviceId(AccountServiceProxy.java:116)
07-18 05:00:12.870: E/StrictMode(692):  at com.android.exchange.ExchangeService.getDeviceId(ExchangeService.java:1249)
07-18 05:00:12.870: E/StrictMode(692):  at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1856)
07-18 05:00:12.870: E/StrictMode(692):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
07-18 05:00:12.870: E/StrictMode(692):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
07-18 05:00:12.870: E/StrictMode(692):  at android.os.AsyncTask$2.call(AsyncTask.java:287)
07-18 05:00:12.870: E/StrictMode(692):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
07-18 05:00:12.870: E/StrictMode(692):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
07-18 05:00:12.870: E/StrictMode(692):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
07-18 05:00:12.870: E/StrictMode(692):  at java.lang.Thread.run(Thread.java:856)
07-18 05:00:12.879: D/dalvikvm(692): GC_CONCURRENT freed 474K, 21% free 2476K/3096K, paused 74ms+75ms, total 197ms
07-18 05:00:12.879: W/ActivityManager(277): Unbind failed: could not find connection for android.os.BinderProxy@4111e8c8

帮助如何克服这样的错误

1 个答案:

答案 0 :(得分:0)

取消绑定/取消注册onStop()

中的服务