My app meet a ServiceConnectionLeaked Error:
    E ActivityThread: android.app.ServiceConnectionLeaked: Activity com.my
has leaked ServiceConnection com.m...@463dc0a0 that was originally bound
here

My app are two part, UI and service, Like music playback, the service will
always running, until user press UI Stop button.
If user press back button, make the UI destory, the service should still
run.

So, I check the Service status, if the service state is not STOPPED, now
playback, then do not unbindService (prevent service be stopped.) but I
receive this ServiceConnectionLeaked.

    public void onDestroy() {
        if (mMyManager.getStatus() == MyService.STATE_STOPPED) {
            if (null != mMyConnection) {
                unbindService(mMyConnection);
                this.stopService(mMyServiceIntent);
                mMyConnection = null;
            }
        } else {
             Log.d(TAG, "Service is run do nothing.");
                }
        super.onDestroy();
    }

What the rigth solution?

Thanks
Ming.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to