如何在安卓中集成Google Plus并获取个人资料信息?

3
我在安卓应用中完成了谷歌+的集成。我的应用程序使用谷歌账户登录。
它显示以下屏幕! 登录界面 在我登录到我的谷歌账户并按照以下步骤操作后 1)它会询问应用程序使用“您的圈子”或“仅限我”,然后我选择“仅限我”。 2)它登录并只显示我的帐户名称。我已经使用loadPerson方法获取个人详细信息...
    @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函数...

    @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());
    }

}

当我选择“仅限我”时,应用程序未显示任何内容,但当我选择“您的圈子”时,它会显示详细信息。

有没有获取详细信息的想法或示例代码?如何完全注销帐户,以便它要求进行新的登录……


请问您能否发布代码? - Smit Patel
1个回答

5
好的,我解决了问题,但这并不明显。原因是SHA1 ID错误。由于您正在使用Run或Debug模式从eclipse运行应用程序,因此您具有不同的SHA1代码。前往Google API控制台并添加调试SHA1代码。

获取方法如下:

  1. 选择应用程序的项目文件夹
  2. 现在转到Window-->Preferences-->Android-->Build
  3. 您将看到它称为SHA1指纹
  4. 为Google API控制台中的相同应用程序创建新的oauth密钥

完成。如果可以,请告诉我是否有效,因为对我有效。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接