2014-11-28 17 views
5

Ich arbeite derzeit an der Google Plus-Anmeldefunktion in meiner App.Plus.PeopleApi.getCurrentPerson gibt null zurück

habe ich GoogleApiClient Builder wie unten

Plus.PlusOptions options = new Plus.PlusOptions.Builder() 
      .addActivityTypes("http://schemas.google.com/AddActivity") 
      .build(); 

    myGoogleApiClient = new GoogleApiClient.Builder(this) 
      .addConnectionCallbacks(this) 
      .addOnConnectionFailedListener(this) 
      // .addApi(Plus.API, Plus.PlusOptions.builder().build()) 
      .addApi(Plus.API, options) 
      .addScope(Plus.SCOPE_PLUS_LOGIN) 
      .addScope(Plus.SCOPE_PLUS_PROFILE).build(); 

Und die onConnected Methode

@Override 
public void onConnected(Bundle arg0) { 
    // TODO Auto-generated method stub 

    plusUtilities.ShowToast("Login successful"); 

    updateGPbutton(); 
    // hide progress DiaLog 
    plusUtilities.DissmissPD(); 
    // it has deprecated 
    // plusUtilities.ShowToast("Login to Google+ with " + 
    // mPlusClient.getAccountName().toString()); 

    // upgraded class 
    plusUtilities.ShowToast("Login to Google+ with " 
      + Plus.AccountApi.getAccountName(myGoogleApiClient).toString()); 

    // deprecated 
    // mPlusClient.loadPeople(this, "me"); 

    Plus.PeopleApi.load(myGoogleApiClient, "me"); 
    // plusUtilities.ShowPD("Fetching user data... "); 

    // upgraded and call fetch_user_details method here instead of calling 
    // in onPersonLoad() override method 
    Log.d("Googleplusclient", 
      "" + Plus.PeopleApi.getCurrentPerson(myGoogleApiClient)); 
    Plus.PeopleApi.loadVisible(myGoogleApiClient, null).setResultCallback(this); 

    if (Plus.PeopleApi.getCurrentPerson(myGoogleApiClient) != null) { 
     Person currentPerson = Plus.PeopleApi 
       .getCurrentPerson(myGoogleApiClient); 
     fetch_User_Details(currentPerson); 
    } 

} 

Die unten Methode gibt null

Plus.PeopleApi.getCurrentPerson (myGoogleApiClient)

I folgte der the link fo r Lösung. Dann folgte ich diesem developer link auch. Bis ich null Wert bekomme.

Wie löst man das?

Antwort

12

Nun, die Sache ist, Ihre DEBUG sha1 Signatur ist anders als Ihre customkey.keystore sha1 Unterschrift !!!! so sollten Sie Ihre debug sha1 Signatur finden und diesen Schlüssel auf den API-Anmeldeinformationen in der Google-Konsole ASWELL erstellen! : D das funktioniert und behebt es mir vertrauen, überprüfen Sie Ihre API-Konsole und ich wette, Ihre API-Anfragen sind 0?

+1

was meinst du mit customkey.keystore sha1 Signatur! ? – tranquil

+1

@tranquil - es bedeutet Ihre Freigabe .keystore, die verwenden sollte, um Ihre Release-/Marktversion der Anwendung zu signieren –