In meiner Anwendung verwende ich Google Plus-Integration. Greifen Sie auch auf die Details des Google-Kontos zu, einschließlich Nutzername, Profilbild usw. Diese Nutzerdaten geben jedoch manchmal einen Nullwert zurück. Bitte hilf mir den Grund zu finden.Android Google + Integration gibt manchmal Nullwerte zurück
Dies ist mein Code:
mGoogleApiClient = new GoogleApiClient.Builder(MainActivity.this)
.addConnectionCallbacks(MainActivity.this)
.addOnConnectionFailedListener(MainActivity.this).addApi(Plus.API,Plus.PlusOptions.builder().build())
.addScope(Plus.SCOPE_PLUS_LOGIN)
.addScope(Plus.SCOPE_PLUS_PROFILE)
.addApi(AppIndex.API).build();
und in onConnected():
@Override
public void onConnected(Bundle bundle) {
String personName="Unknown";
gmail = Plus.AccountApi.getAccountName(
(GoogleApiClient) mGoogleApiClient).toString();
try {
String[] id = gmail.split("@");
try {
plusid = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient).getId();
} catch (NullPointerException e) {
plusid = id[0];
}
plusimage = Plus.PeopleApi
.getCurrentPerson((GoogleApiClient) mGoogleApiClient)
.getImage().getUrl().toString();
plusname = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient).getDisplayName().toString();
}
if (CheckNetworkConnection.isConnectionAvailable(MainActivity.this)) {
// new SocialLogin().execute();
}
} catch (NullPointerException e) {
Toast.makeText(getApplicationContext(), "GMAIL" + gmail, Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), "ID" +plusid , Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), "NAME" + plusname, Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), "IMG" + plusimage, Toast.LENGTH_SHORT).show();
Toast.makeText(MainActivity.this, "Google plus account not configured correctly", Toast.LENGTH_SHORT).show();
dialog.dismiss();
}
}
hier plusimage und plusname Rückkehr null.Please mir helfen, den Grund zu finden.
Ohne uns einen Code zur Verfügung zu stellen, wird es ziemlich schwierig zu finden, wo in Ihrem Code das Problem herkommt. Bitte lesen Sie diese Dokumentation - http://stackoverflow.com/help/how-to-ask - bevor Sie eine Frage stellen. – jeffdill2
@ jeffdill2 Sorry.Question Edited – krishna
@ Krishna Verwenden Sie dieses Beispiel als Referenz möglicherweise funktioniert es für Sie .. https://github.com/googlesamples/google-services/blob/master/android/signin/app/src/main /java/com/google/samples/quickstart/signin/SignInActivity.java#L51-L55 –