Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Play Location Not connected. Call connect() and wait for onConnected() to be called

I am getting very strange crash for some of my users. I am using Google Play Services and the Location service. The error is:

Not connected. Call connect() and wait for onConnected() to be called.

The relevant function in the code that it says is causing the crash is:

  @Override
  public void onConnected(Bundle bundle) {

      if (debug) {
          Toast.makeText(this, DateFormat.getDateTimeInstance().format(new Date()) + ": Connected.", Toast.LENGTH_SHORT).show();
      }

      // Request location updates using static settings
      setUpLocationClientIfNeeded();
      mLocationClient.requestLocationUpdates(mLocationRequest, this);<---- Crash here

  }

The strange thing is, I can't replicate this crash in my own testing, so I can't figure out why this would be happening.

like image 529
Nic Hubbard Avatar asked Oct 20 '22 19:10

Nic Hubbard


1 Answers

put mLocationClient.connect() before your requestLocationUpdates method. Worked for me.

like image 184
Ogen Avatar answered Oct 24 '22 09:10

Ogen