Android Audio Service已泄露服务连接

我正在开发音乐播放器的应用程序.
我面临的错误就像.

‘* .MusicPlayerTabWidget已泄露ServiceConnection *

请给你评论.
我也分享了我的Logcat.

05-01 10:38:03.226: W/KeyCharacterMap(4225): Using default keymap
05-01 10:38:03.429: E/ActivityThread(4225): Activity com.pvMusic.pvm.MusicPlayerTabWidget has leaked ServiceConnection com.pvMusic.pvm.MusicPlayerTabWidget$1@4051c6f0 that was originally bound here
05-01 10:38:03.429: E/ActivityThread(4225): android.app.ServiceConnectionLeaked: Activity com.pvMusic.pvm.MusicPlayerTabWidget has leaked ServiceConnection com.pvMusic.pvm.MusicPlayerTabWidget$1@4051c6f0 that was originally bound here
05-01 10:38:03.429: E/ActivityThread(4225):     at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:938)
05-01 10:38:03.429: E/ActivityThread(4225):     at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:833)
05-01 10:38:03.429: E/ActivityThread(4225):     at android.app.ContextImpl.bindService(ContextImpl.java:879)
05-01 10:38:03.429: E/ActivityThread(4225):     at android.content.ContextWrapper.bindService(ContextWrapper.java:347)
05-01 10:38:03.429: E/ActivityThread(4225):     at com.pvMusic.pvm.MusicPlayerTabWidget.onStart(MusicPlayerTabWidget.java:175)
05-01 10:38:03.429: E/ActivityThread(4225):     at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1129)
05-01 10:38:03.429: E/ActivityThread(4225):     at android.app.Activity.performStart(Activity.java:3791)
05-01 10:38:03.429: E/ActivityThread(4225):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1624)
05-01 10:38:03.429: E/ActivityThread(4225):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
05-01 10:38:03.429: E/ActivityThread(4225):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-01 10:38:03.429: E/ActivityThread(4225):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
05-01 10:38:03.429: E/ActivityThread(4225):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-01 10:38:03.429: E/ActivityThread(4225):     at android.os.Looper.loop(Looper.java:130)
05-01 10:38:03.429: E/ActivityThread(4225):     at android.app.ActivityThread.main(ActivityThread.java:3687)
05-01 10:38:03.429: E/ActivityThread(4225):     at java.lang.reflect.Method.invokeNative(Native Method)
05-01 10:38:03.429: E/ActivityThread(4225):     at java.lang.reflect.Method.invoke(Method.java:507)
05-01 10:38:03.429: E/ActivityThread(4225):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
05-01 10:38:03.429: E/ActivityThread(4225):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
05-01 10:38:03.429: E/ActivityThread(4225):     at dalvik.system.NativeStart.main(Native Method)
05-01 10:39:31.859: D/dalvikvm(4225): GC_EXPLICIT freed 166K, 46% free 3022K/5575K, external 557K/1031K, paused 52ms
05-01 10:39:31.906: D/dalvikvm(4225): GC_CONCURRENT freed 0K, 46% free 3022K/5575K, external 557K/1031K, paused 4ms+3ms

更多内容如果您有音乐播放器的参考教程请与我分享..

解决方法:

添加unbindService(mConnection);在你的onstop()方法中.代码将开始正常工作.

上一篇:在Android中创建游戏引力(续)?


下一篇:Android:高效的读取logcat输出的方法