0

I have an app that uses Android Wear API. To create it I followed the guides here:

https://developer.android.com/training/building-wearables.html

I access the wearable APIs using:

new GoogleApiClient.Builder(context)
    .addConnectionCallbacks(this)
    .addOnConnectionFailedListener(this)
    .addApi(Wearable.API)
    .build();

In my onConnectionFailedListener, I am getting an error code 16, resulting in a popup to the user saying "GooglePlayServicesUtil﹕ Unexpected error code 16".

@Override
public void onConnectionFailed(ConnectionResult result) {
    if (mResolvingError) {
        // Already attempting to resolve an error.
        return;
    } else if (result.hasResolution()) {
        try {
            mResolvingError = true;
            result.startResolutionForResult(this, REQUEST_RESOLVE_ERROR);
        } catch (SendIntentException e) {
            // There was an error with the resolution intent. Try again.
            mGoogleApiClient.connect();
        }
    } else {
        // Show dialog using GooglePlayServicesUtil.getErrorDialog()
        showErrorDialog(result.getErrorCode());
        mResolvingError = true;
    }
}

I couldn't find an answer to why this happens in an SO question, so I will add my own.

Jon G
  • 1,656
  • 3
  • 16
  • 42

1 Answers1

0

When setting up my Android Wear client, I had missed a wear specific part. See:

https://developer.android.com/google/auth/api-client.html#Starting

"Access the Wearable API"

// Connection failed listener method for a client that only
// requests access to the Wearable API
@Override
public void onConnectionFailed(ConnectionResult result) {
    if (result.getErrorCode() == ConnectionResult.API_UNAVAILABLE) {
        // The Android Wear app is not installed
    }
    ...
}

Adding this in to my onConnectionFailedListener solved my problem. The Android Wear app was not installed on those devices.

Jon G
  • 1,656
  • 3
  • 16
  • 42