title: GoogleApiClient is not connected yet , on a location application
body: <p>im trying to get the city and country from a location but i am catchinf an exception : GoogleApiClient is not connected yet</p>
  
  <pre><code> protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_weather);`
  `if (checkPlayServices()) {
          buildGoogleApiClient();
          createLocationRequest();
      }
  
      displayLocation();
      togglePeriodicLocationUpdates();}
  private boolean checkPlayServices() {
          int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
          if (resultCode != ConnectionResult.SUCCESS) {
              if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
                  GooglePlayServicesUtil.getErrorDialog(resultCode, this, PLAY_SERVICES_RESOLUTION_REQUEST).show();
              } else {
                  Toast.makeText(getApplicationContext(),
                          "This device is not supported.", Toast.LENGTH_LONG)
                          .show();
                  finish();
              }
              return false;
          }
          return true;
      }
  
      protected synchronized void buildGoogleApiClient() {
          mGoogleApiClient = new GoogleApiClient.Builder(this)
                  .addConnectionCallbacks(this)
                  .addOnConnectionFailedListener(this)
                  .addApi(LocationServices.API).build();
      }
  
      private void displayLocation() {
  
          mLastLocation = LocationServices.FusedLocationApi
                  .getLastLocation(mGoogleApiClient);
  
          if (mLastLocation != null) {
              double latitude = mLastLocation.getLatitude();
              double longitude = mLastLocation.getLongitude();
              Geocoder geoCoder = new Geocoder(this, Locale.getDefault());
              StringBuilder builder = new StringBuilder();
              try {
                  List&lt;Address&gt; address = geoCoder.getFromLocation(latitude, longitude, 1);
                  city = address.get(0).getLocality();
                  country = address.get(0).getCountryName();
  
  
              } catch (IOException e) {
              } catch (NullPointerException e) {
              }
  
  
          } else {
  
              Toast.makeText(this, "erreur", Toast.LENGTH_LONG).show();
          }
      }
  
  
      @Override
      public void onConnected(Bundle bundle) {
          displayLocation();
          if (mRequestingLocationUpdates) {
              startLocationUpdates();
          }
  
      }
  
      @Override
      public void onConnectionSuspended(int i) {
          mGoogleApiClient.connect();
  
      }
  
      @Override
      public void onConnectionFailed(ConnectionResult result) {
          Log.i(TAG, "Connection failed: ConnectionResult.getErrorCode() = "
                  + result.getErrorCode());
  
      }
  
      @Override
      protected void onStart() {
          super.onStart();
          if (mGoogleApiClient != null) {
              mGoogleApiClient.connect();
          }
      }
  
      @Override
      protected void onResume() {
          super.onResume();
  
          checkPlayServices();
          if (mGoogleApiClient.isConnected() &amp;&amp; mRequestingLocationUpdates) {
              startLocationUpdates();
          }
      }
  
      @Override
      protected void onStop() {
          super.onStop();
          if (mGoogleApiClient.isConnected()) {
              mGoogleApiClient.disconnect();
          }
      }
  
      @Override
      protected void onPause() {
          super.onPause();
          stopLocationUpdates();
      }
  
  
      @Override
      public void onLocationChanged(Location location) {
          // Assign the new location
          mLastLocation = location;
  
          Toast.makeText(getApplicationContext(), "Location changed!",
                  Toast.LENGTH_SHORT).show();
  
          // Displaying the new location on UI
          displayLocation();
  
      }
  
      private void togglePeriodicLocationUpdates() {
          if (!mRequestingLocationUpdates) {
  
              mRequestingLocationUpdates = true;
  
              // Starting the location updates
              startLocationUpdates();
  
              Log.d(TAG, "Periodic location updates started!");
  
          } else {
              // Changing the button text
  
              mRequestingLocationUpdates = false;
  
              // Stopping the location updates
              stopLocationUpdates();
  
              Log.d(TAG, "Periodic location updates stopped!");
          }
      }
  
      protected void createLocationRequest() {
          mLocationRequest = new LocationRequest();
          mLocationRequest.setInterval(UPDATE_INTERVAL);
          mLocationRequest.setFastestInterval(FATEST_INTERVAL);
          mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
          mLocationRequest.setSmallestDisplacement(DISPLACEMENT); // 10 meters
      }
  
      protected void startLocationUpdates() {
  
          LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
  
      }
  
      protected void stopLocationUpdates() {
          LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient,this);
      }
  </code></pre>
  
  <p>does anyone know why i am getting this Exception , because i already connected the api in the onStart() method !! </p>
  
  <p>any answer would be helpful :D</p>