Android Google Login Button

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

When you click the button, a pop-up window appears asking for your permission: Know who you are on Google.

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

What is it good for?

* Please don't tell me how to get access_token, this is not a question about

+3


source to share


2 answers


You need to implement ConnectionCallbacks. And in onConnected () you can start fetching user data from google plus account. Here's my example code for a 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 link: Person

+1


source


Your class must implement ConnectionCallbacks, and one of the provided methods is the onConnected () method. When the thread reaches your implementation of the onConnected () method (which means you have successfully established a connection to Google), you can call let say mPlusClient.getCurrentPerson (). The return type is an instance of the Person class, where you can find something about the person who selected google plus login.



0


source







All Articles