Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Google plus sign in button

Following Google Sign Button, I implemented it on my android device.

When clicking the button it shows you a popup asking your permission: Know Who you are on Google.

Now what? It looks like this gives me nothing. It does not provide me access_token, or any user data.

What is it good for?

*Please do not tell me how to get access_token this is not what the question is about

like image 324
Ilya Gazman Avatar asked Jan 17 '26 17:01

Ilya Gazman


1 Answers

You have to implement ConnectionCallbacks. And in onConnected(), you can start to get user data you want from the google plus account. Here's my sample code for the function:

    @Override
public void onConnected(Bundle connectionHint) {
    // We've resolved any connection errors.
    mConnectionProgressDialog.dismiss();
    String accountName = mPlusClient.getAccountName();
    Person p = mPlusClient.getCurrentPerson();
    String displayName = p.getDisplayName();
    google_text.setText(String.format("email:%s\ndisplay name:%s",accountName, displayName));

}

You can see more Person data in Google's link: Person

like image 146
Daniel Kao Avatar answered Jan 20 '26 10:01

Daniel Kao