onConnectionFailed mit SIGN_IN_REQUIRED (4)

Ich bin die Entwicklung einer Android-Anwendung, wo ich Sie benutzen will die Google-API. Für die, die ich importiert haben, die google-play-Services-lib Projekt.

Ich bin nach dieser link zu initialisieren GoogleApiClient Objekt.

Mein code:

1) In der onCreate() Methode Baue ich die GoogleApiClient Objekt:

mGoogleApiClient = new GoogleApiClient.Builder(this)
    .addConnectionCallbacks(this)
    .addOnConnectionFailedListener(this)
    .addApi(Plus.API, null)
    .addScope(Plus.SCOPE_PLUS_LOGIN)
    .build();

2) onStart() rufe ich mGoogleApiClient.connect().

3) Meine Aktivität implementiert
ConnectionCallbacks und OnConnectionFailedListener.

4) Meine onConnectionFailed() Methode sieht wie folgt aus:

public void onConnectionFailed(ConnectionResult result) {
    //in dubug result looks like : ConnectionResult{
    //statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent
                    //{41f8ca70: android.os.BinderProxy@41f8ca10}}
     try {
     if(!mIntentInProgress && result.hasResolution())
     {
         mIntentInProgress=true;
        result.startResolutionForResult(mActivity, RC_SIGN_IN);
          }

    } catch (SendIntentException e) {
        e.printStackTrace();
    }
}

5) Mein onActivityResult() - Methode enthält:

if (requestCode == RC_SIGN_IN) {
   if (!mGoogleApiClient.isConnecting()) {
      mGoogleApiClient.connect();
   }
}

Wenn ich meine app, die ich bekommen Toastdie besagt, dass ein interner Fehler aufgetaucht. Ich habe das Projekt erstellen in der Google-Konsole.

InformationsquelleAutor der Frage DCoder | 2014-05-19

Schreibe einen Kommentar