Nilesh Patel
Nilesh Patel

Reputation: 419

How to integrate google plus in android and get profile information?

I have done Google plus integration in android. in my application it login with google account.

it diplay below screen! Login screen

and after i login to my google account and i follow the steps 1) it ask application use your circle or only me then i select only me. 2) it signing in and display only my account name.I have used loadPerson method to get person detail...

    @Override
public void onConnected(Bundle connectionHint) 
{
    mConnectionProgressDialog.dismiss();
    String accountName = mPlusClient.getAccountName();
    //mPlusClient.loadPeople(this, Person.Collection.VISIBLE);
    Log.d("User", "Account Name = "+accountName);

    Toast.makeText(GooglePlusActivity.this, "Welcome "+accountName, Toast.LENGTH_SHORT).show();


    final String account = mPlusClient.getAccountName();



    mPlusClient.loadPerson(this, "me");

}

onPersonload function...

    @Override
public void onPersonLoaded(ConnectionResult status, Person person) {
    // TODO Auto-generated method stub
    if (status.getErrorCode() == ConnectionResult.SUCCESS) {
        Log.d("GooglePlusActivity", "Display Name: " + person.getDisplayName());
        Toast.makeText(this, "Display name:"+person.getDisplayName(), Toast.LENGTH_SHORT).show();
        Toast.makeText(this, "about me:"+person.getAboutMe(), Toast.LENGTH_SHORT).show();
        Toast.makeText(this, "id:"+person.getId(), Toast.LENGTH_SHORT).show();
        Toast.makeText(this, "Name:"+person.getName(), Toast.LENGTH_SHORT).show();
        Toast.makeText(this, "Birthdate:"+person.getBirthday(), Toast.LENGTH_SHORT).show();
        Toast.makeText(this, "Gender:"+person.getGender(), Toast.LENGTH_SHORT).show();

    }
    else
    {
        Log.d("Error", "Connection error::"+status.getErrorCode());
    }

}

then it display nothing when i select application use as Only me but it display detail when select "your circle"

is there any idea or sample code for getting detail. and how to fully sign out from account.so it should ask for new login....

Upvotes: 3

Views: 3425

Answers (1)

SARose
SARose

Reputation: 3725

Okay I solved the problem and it isn't obvious. It is because the SHA1 ID is wrong. Since you are running the app from eclipse using Run or Debug mode you have a different SHA1 code. Go to the google api console and add the debug SHA1 code.

You get it by

  1. Select the project folder for the App
  2. Now go to Window-->Perferences-->Android-->Build
  3. You will see it called SHA1 fingerprint
  4. Create a new oauth key for in the same application in the Google API Console

Done. Tell me if that worked because it worked for me. Up vote if it did please.

Upvotes: 5

Related Questions