0
// Setup
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
    .requestScopes(new Scope(PeopleScopes.CONTACTS_READONLY))
    .build();

mGoogleClient = new GoogleApiClient.Builder(context)
    .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
    .addConnectionCallbacks(this)
    .addOnConnectionFailedListener(this)
    .build();

// Login
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleClient);
mActivity.startActivityForResult(signInIntent, REQUEST_CODE_LOGIN);

// Restore Login
// mGoogleClient.connect(GoogleApiClient.SIGN_IN_MODE_OPTIONAL);

这是我处理登录结果的方式:

public void onActivityResult(int requestCode, int responseCode, Intent data)
{
    if (mGoogleClient != null && requestCode == REQUEST_CODE_LOGIN)
    {
        mLoginResult = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (mLoginResult.isSuccess())
        {
            getAllContacts();
        }
    }
}

问题来了,我怎样才能转换这种旧的感冒?我想继续使用GoogleApiClient.

private void getAllContacts()
{
    // 1) Own Profil
    Person pMe = Plus.PeopleApi.getCurrentPerson(mGoogleClient);

    // 2) Friends
    PendingResult<People.LoadPeopleResult> result = Plus.PeopleApi.loadVisible(mGoogleClient, People.OrderBy.BEST, null);
    People.LoadPeopleResult loadPeopleResult = result.await();
    if (loadPeopleResult.getStatus().isSuccess())
    {
        PersonBuffer people = loadPeopleResult.getPersonBuffer();
        for (Person p : people)
        {
            // ...
        }
        people.close();
    }
}

我想要的是

我想在GoogleApiClient. 有谁知道如何实现这一目标?

4

0 回答 0