Ich habe versucht, Google-Anmeldung in meine Android-Anwendung zu integrieren, aber jedes Mal gibt es ein falsches Ergebnis. Ich habe die JSON-Konfigurationsdatei sowie überprüft die Gradle-Dateien auch enthalten. Bitte helfen, ich stecke fest. Hier ist mein CodeGoogle-Anmeldung nicht möglich?
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
SignInButton signInButton = (SignInButton) findViewById(R.id.sign_in_button);
signInButton.setSize(SignInButton.SIZE_STANDARD);
signInButton.setScopes(gso.getScopeArray());
}
@Override
public void onStart() {
super.onStart();
OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
if (opr.isDone()) {
Log.d(TAG, "Got cached sign-in");
GoogleSignInResult result = opr.get();
handleSignInResult(result);
} else {
showProgressDialog();
opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
@Override
public void onResult(GoogleSignInResult googleSignInResult) {
hideProgressDialog();
handleSignInResult(googleSignInResult);
}
});
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
int statusCode = result.getStatus().getStatusCode();
Log.d(statusCode+"oo", "joij");
handleSignInResult(result);
}
}
private void handleSignInResult(GoogleSignInResult result) {
Log.d(TAG, "handleSignInResult:" + result.isSuccess());
Log.d(result+"hello", "hii me prateek");
if (result.isSuccess()) {
GoogleSignInAccount acct = result.getSignInAccount();
mStatusTextView.setText("done");
updateUI(true);
} else {
mStatusTextView.setText("not done");
// Signed out, show unauthenticated UI.
updateUI(false);
}
}
private void signIn() {
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);
}
private void revokeAccess() {
Auth.GoogleSignInApi.revokeAccess(mGoogleApiClient).setResultCallback(
new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
// [START_EXCLUDE]
updateUI(false);
// [END_EXCLUDE]
}
});
}
haben Sie Zeile für Zeile debuggen ??? Was ist der Wert von '' 'GoogleSignInResult Ergebnis'''' –
[email protected]0 –
Rakesh Kashyap, es ist von diesem Format. –