1

Good day.I am trying to call the api method.All goes good,the screen of login is being represented to user with request of its circles,and boom as soon as im trying to get the people list from circles it goes with error always!

Status{statusCode=NETWORK_ERROR, resolution=null}

I dont know what it causing and by googling i found nothing closer to my issue so ill post an code how i do call this method. Here how i build and call it.

 public synchronized GoogleApiClient buildGoogleApiClient(final Activity activity) {
    GoogleSignInOptions gGoogleSignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestScopes(new Scope(Scopes.PROFILE))
            .requestScopes(new Scope(Scopes.PLUS_LOGIN))
            .requestProfile()
            .requestEmail()
            .build();

    mGoogleApiClient = new GoogleApiClient.Builder(activity)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gGoogleSignInOptions)
            .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
                @Override
                public void onConnected(@Nullable Bundle bundle) {
                    Plus.PeopleApi.loadVisible(mGoogleApiClient, "me").setResultCallback(new ResultCallbacks<People.LoadPeopleResult>() {
                        @Override
                        public void onSuccess(@NonNull People.LoadPeopleResult loadPeopleResult) {
                            Toast.makeText(activity, "", Toast.LENGTH_SHORT).show();
                            Person person = loadPeopleResult.getPersonBuffer().get(0);
                            Log.d("fasfafasfsafasfas", "onSuccess: " + person);
                        }

                        @Override
                        public void onFailure(@NonNull Status status) {
                            if (status.hasResolution()) {
                                try {
                                    // !!!
                                    status.startResolutionForResult(activity, 100);
                                } catch (IntentSender.SendIntentException e) {
                                    mGoogleApiClient.connect();
                                }
                            }
                            Log.d("fasfafasfsafasfas", "onFailure: " + status);
                        }

                    });

                }

                @Override
                public void onConnectionSuspended(int i) {
                    Toast.makeText(activity, "fail", Toast.LENGTH_SHORT).show();
                }
            })
            .addApi(Plus.API)
            .build();
    mGoogleApiClient.connect(GoogleApiClient.SIGN_IN_MODE_OPTIONAL);
    return mGoogleApiClient;
}

It always goes into onFailure callback with network error..I dont know whats wrong i have typed... here is permissions required in manifest

    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />

So please do tell me whats wrong with my code?

4

1 回答 1

0

如果有人遇到同样的问题,这里就是解决方案。你不需要在获取圈子时指定“我”,同时像这样指定 NULL

  Plus.PeopleApi.loadVisible(mGoogleApiClient, null
                    ).setResultCallback(new ResultCallbacks<People.LoadPeopleResult>() {
                        @Override
                        public void onSuccess(@NonNull People.LoadPeopleResult loadPeopleResult) {
                            int personCount = loadPeopleResult.getPersonBuffer().getCount();
                            Log.d("fasfafasfsafasfas", "onSuccess: " + personCount);
                            for (int i = 0; i < personCount; i++) {
                                Person eachPerson = loadPeopleResult.getPersonBuffer().get(i);
                                Log.d("fasfafasfsafasfas", "onSuccess: " + eachPerson.getImage().getUrl());
                            }
                        }

                        @Override
                        public void onFailure(@NonNull Status status) {
                            if (status.hasResolution()) {
                                try {
                                    status.startResolutionForResult(activity, requestCode);
                                } catch (IntentSender.SendIntentException e) {
                                    mGoogleApiClient.connect();
                                }
                            }
                            Log.d("fasfafasfsafasfas", "onFailure: " + status);
                        }

                    });
于 2016-08-29T07:29:10.603 回答