【问题标题】:Google plus unable to load peopleGoogle+ 无法加载人员
【发布时间】:2013-12-30 08:10:55
【问题描述】:

我尝试在我的 Android 应用程序中使用 google plus api。 I follow sample code

我已成功连接到 google plus,并请求加载人员,但 personBuffer 计数为 0。但我的群组中有一些人。

请告诉我任何想法?也许我忘记了任何附加范围?我只添加 Scopes.PLUS_LOGIN。在文档中就足够了。

我的完整授权码:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mPlusClient = new PlusClient.Builder(this, this, this).setScopes(Scopes.PLUS_LOGIN, Scopes.PLUS_PROFILE)
                .setVisibleActivities("http://schemas.google.com/AddActivity").build();

        // Progress bar to be displayed if the connection failure is not
        // resolved.
        mConnectionProgressDialog = new ProgressDialog(this);
        mConnectionProgressDialog.setMessage("Signing in...");

    }


@Override
    protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
        if (requestCode == REQUEST_CODE_RESOLVE_ERR && responseCode == RESULT_OK) {
            mConnectionResult = null;
            mPlusClient.connect();
        }
    }
@Override
    public void onConnected(Bundle connectionHint) {
        String accountName = mPlusClient.getAccountName();
//      mPlusClient.loadPerson(this, "104242357859551899867");
//
        mPlusClient.loadPeople(MainActivity.this, Person.Collection.VISIBLE);

        Toast.makeText(this, accountName + " is connected. try to load persons", Toast.LENGTH_LONG).show();
    }
@Override

public void onPeopleLoaded(ConnectionResult status, PersonBuffer personBuffer, String nextPageToken) {
    Log.i("", "persons loaded result = " + status.toString() + ", personsCount = " + personBuffer.getCount()
            + ", token = " + nextPageToken);
    if (status.isSuccess()) {
        Iterator<Person> itP = personBuffer.iterator();
        while (itP.hasNext()) {
            Person person = itP.next();
            Log.i("", person.getNickname());
        }
    }

}

我的完整日志:

    06-14 11:38:43.451: D/libEGL(779): loaded /system/lib/egl/libEGL_adreno200.so
06-14 11:38:43.451: D/libEGL(779): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
06-14 11:38:43.451: D/libEGL(779): loaded /system/lib/egl/libGLESv2_adreno200.so
06-14 11:38:43.451: I/Adreno200-EGL(779): <eglInitialize:269>: EGL 1.4 QUALCOMM build: Nondeterministic AU_full_mako_PARTNER-ANDROID/JB-MR1-DEV_CL2961380_release_AU (CL2961380)
06-14 11:38:43.451: I/Adreno200-EGL(779): Build Date: 12/10/12 Mon
06-14 11:38:43.451: I/Adreno200-EGL(779): Local Branch: 
06-14 11:38:43.451: I/Adreno200-EGL(779): Remote Branch: m/partner-android/jb-mr1-dev
06-14 11:38:43.451: I/Adreno200-EGL(779): Local Patches: NONE
06-14 11:38:43.451: I/Adreno200-EGL(779): Reconstruct Branch: NOTHING
06-14 11:38:43.491: D/OpenGLRenderer(779): Enabling debug mode 0
06-14 11:38:44.993: I/(779): persons loaded result = ConnectionResult{statusCode=SUCCESS, resolution=null}, personsCount = 0, token = null
06-14 11:38:45.013: D/dalvikvm(779): GC_CONCURRENT freed 165K, 3% free 8898K/9092K, paused 2ms+3ms, total 27ms

【问题讨论】:

  • 确保您的 google plus 帐户拥有所有详细信息或尝试使用其他 google plus 帐户登录
  • 我尝试登录另一个帐户,都一样
  • 好的,粘贴完整的logcat
  • 我将完整的 logcat 添加到帖子中
  • 你想加载一个人还是几个人?

标签: android google-plus


【解决方案1】:

解决方法是这样初始化PlusClient:

mPlusClient = new PlusClient.Builder(this, this, this).build();

以上代码运行良好。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多