谷歌加上无法加载人

时间:2013-06-14 06:51:38

标签: android google-plus

我尝试在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());
        }
    }

}

我完整的logcat:

    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

1 个答案:

答案 0 :(得分:0)

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

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

上面的代码工作正常。