ServiceConnectionLeaked in Android

As you call the doBindService() in the onCreate(), you should add the do UnbindService() in onDestroy().

It works for me.


You need to use the good reference for the Activity getActivity() return the current one, and you need to unbind on the one which did the bind

here's how I fixed the problem :

private Activity mActivity;
    @Override
    public void onStart() {
        super.onStart();
        if (!mBound) {
            startService();
            mActivity = getActivity();
        }
    }

    @Override
    public void onStop() {
        super.onStop();
        if (mBound && mActivity != null) {
            mActivity.unbindService(mServiceConnection);
            mActivity = null;
        }
    }

You're calling doBindService() in both onCreate() and onResume(), trying calling it just in onResume() to match your call to doUnbindService() in onPause()