我正在开发音乐播放器的应用程序。
我面临着错误。
'*.musicplayertabwidget已泄漏服务连接*
请对此发表意见。
我也为此分享我的日志。

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()。代码将开始正常工作。

08-03 18:51