Jak powiązać usługę z fragmentem

Próbuję powiązać usługę z fragmentu w taki sam sposób, w jaki zrobiłem to pomyślnie w działaniu, ale gdy próbuję wywołać metodę w usłudze, otrzymuję wyjątek NullPointerException - oczywiście, ponieważ usługa ma wartość NULL. Czy jest jakiś problem z powiązaniem z usługą w OnStart, czy po prostu robię to źle?

@Override
public void onStart() {
    super.onStart();

    Intent intent = new Intent(getActivity(), LiteTrickService.class);
    getActivity().registerReceiver(receiver, new IntentFilter(LiteTrickService.BROADCAST_ACTION));
    getActivity().registerReceiver(receiver, new IntentFilter(LiteTrickService.BROADCAST_FAIL));
    getActivity().bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
}

@Override
public void onStop() {
    super.onStop();
    getActivity().unbindService(mConnection);
    getActivity().unregisterReceiver(receiver);
    mBound = false;
}

edytować: Przepraszam. To mój błąd, że nie zadałem tego pytania wystarczająco długo. mConnection jest ServiceConnection i wygląda tak:

private ServiceConnection mConnection = new ServiceConnection() 
{

    @Override
    public void onServiceConnected(ComponentName className,
            IBinder service) {
        // We've bound to LocalService, cast the IBinder and get LocalService instance
        LocalBinder binder = (LocalBinder) service;
        mService = binder.getService();
        mBound = true;
    }

    @Override
    public void onServiceDisconnected(ComponentName arg0) {
        mBound = false;
    }
};

Ślad stosu :

01-03 15:21:22.355: E/AndroidRuntime(12360): FATAL EXCEPTION: main
01-03 15:21:22.355: E/AndroidRuntime(12360): java.lang.NullPointerException
01-03 15:21:22.355: E/AndroidRuntime(12360):    at lite.hattrick.players.PlayerRankingFragment.onOptionsItemSelected(PlayerRankingFragment.java:205)

I to jest dokładne miejsce, w którym wyjątek jest generowany: case POPULATE_ID:

        if (hasData) {
            return false;
        }
        if(!mBound)
            getActivity().bindService(new Intent(getActivity().getApplicationContext(), LiteTrickService.class), mConnection, Context.BIND_AUTO_CREATE);
        mService.refreshPlayers(); // Null Pointer Exception as mService is null
        pBar.setVisibility(View.VISIBLE);
        return true;

questionAnswers(2)

yourAnswerToTheQuestion