title: LocationClient not connected although onConnected was called
body: <p>In my application I'm trying to use the LocationService based on Google's tutorial "Retrieving the Current Location" (<a href="http://developer.android.com/training/location/retrieve-current.html" rel="nofollow">http://developer.android.com/training/location/retrieve-current.html</a>).
  Unfortunately when I actually need it I get a <strong>'IllegalStateException: Not connected. Call connect() and wait for onConnected'</strong> exception.
  I need the location service for a very short period - on pressing
  some button I want to get the current location (or last known location).
  My LocationHandler code is as follows:</p>
  
  <pre><code>class LocationHandler implements GooglePlayServicesClient.ConnectionCallbacks,
                                  GooglePlayServicesClient.OnConnectionFailedListener {
  
      private MainActivity m_ma;
      private LocationClient m_locationClient;
      private boolean m_isAvailable = false;
  
  
      //ctor
      LocationHandler(MainActivity ma) {
          m_ma = ma;
          m_locationClient = new LocationClient(ma, this, this);
      }
  
      @Override
      public void onConnected(Bundle dataBundle) {
          // Display the connection status
          Toast.makeText(m_ma, "Connected", Toast.LENGTH_SHORT).show();
          m_isAvailable = true;
          Log.i(TAG, "LOCATION = " + m_locationClient.getLastLocation());
      }
  
      @Override
      public void onDisconnected() {
          // Display the connection status
          Toast.makeText(m_ma, "Disconnected."
                  Toast.LENGTH_SHORT).show();
          m_isAvailable = false;
          Log.i(TAG, "LOCATION dis-connected");
      }
  
      @Override
      public void onConnectionFailed(ConnectionResult connectionResult) {
  
          m_isAvailable = false;
          Log.i(TAG, "LOCATION failed");
          ... code from tutorial
      }
  
      //connect the LocationClient
      void connectLocationClient() {
          m_locationClient.connect();
      }
  
      //disconnect the LocationClient
      void diconnectLocationClient() {
          m_locationClient.disconnect();
      }
  
      //
      Location getCurrentLocation() {
          connectLocationClient();
          if(m_isAvailable) {
              Log.i(TAG, "3333333333333333 m_locationClient.isConnected() = " + m_locationClient.isConnected());
              return m_locationClient.getLastLocation();
          } else {
              Log.i(TAG, "444444444444");
              Toast.makeText(m_ma, "Location Services is not yet avaialable",
                      Toast.LENGTH_SHORT).show();
              return null;
          }
      }
  }
  </code></pre>
  
  <p>The button's onClick code calls the <code>getCurrentLocation()</code> method.
  On the first click I obviously get a null Location and the "... not yet available" Toast.
  Then <code>onConnected(..)</code> callback is invoked and <code>getLastLocation()</code> inside it succeeds.
  Then when I press again on the button I get the <code>IllegalStateException</code> since the LocationClient
  is not connected.
  How come it is not connected if I already seen that <code>onConnected()</code> was invoked, but didn't seen neither <code>onDisconnected()</code> nor <code>onConnectionFailed(..)</code> being called?</p>