title: Service is not initialized, returns NullPointerException
body: <p>I am trying to get two-way communication between my Service and Activity set up.  To do this, I start my Service like normal, send a Message with the replyTo set to the Messenger in my Activity, and send it to my Service.  That way I have a reference to send messages in both directions.  Here is some relevant code in my Activty:</p>
  
  <pre><code>private Messenger mService = null;
  private final Messenger mMessenger = new Messenger(new IncomingHandler());
  
  private ServiceConnection mConnection = new ServiceConnection()
  {
      public void onServiceConnected(ComponentName className, IBinder service)
      {
          mService = new Messenger(service);
          mBound = true;
      }
  
      public void onServiceDisconnected(ComponentName className)
      {
          mService = null;
          mBound = false;
      }
  };
  
  private void initMessenger()
  {
      Message messageHandler = Message.obtain(null, NetworkService.MSG_GET_HANDLER, 0, 0);
      messageHandler.replyTo = mMessenger; //Set the replyTo to give a reference
      try
      {
          mService.send(messageHandler);
      }
      catch(RemoteException e)
      {
          e.printStackTrade();
      }
      catch(NullPointerException e)
      {
          e.printStackTrace(); //Why!!!
      }
  }
  
  public void onCreate()
  {
  ...
      //Create the intent to start the network service
      Intent iService = new Intent(this, NetworkService.class);
      int[] connectionConfig = {CONNECTION_BT};
      iService.putExtra(CONNECTION_CONFIG, connectionConfig);
      bindService(iService, mConnection, Context.BIND_ABOVE_CLIENT);
      startService(iService);
      initMessenger();
  }
  </code></pre>
  
  <p>A NullPointerException is thrown when I try to call mService.send(), most likely because mService is null at the time.  If I move the initMessenger() code inside a Button's OnClickListener it works fine which is where the confusion comes in.  Am I supposed to wait a certain amount of time after starting a Service to use it?</p>