I want to create a Google sign for my app but my result code from onActivityResult() is 0
In my onCreate() Method I start the function startSignInIntent() like this:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//some other stuff
view.loadUrl(myURL);
startSignInIntent();
}
This is the startSignInIntent()
private void startSignInIntent() {
GoogleSignInClient signInClient = GoogleSignIn.getClient(this,
GoogleSignInOptions.DEFAULT_SIGN_IN);
Intent intent = signInClient.getSignInIntent();
startActivityForResult(intent, RC_SIGN_IN);
}
This is the onActivityResult()
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.d(TAG, "data : " + resultCode + " | " + data + " || " + RC_SIGN_IN + " ||| " + requestCode);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
// The signed in account is stored in the result.
GoogleSignInAccount signedInAccount = result.getSignInAccount();
} else {
String message = result.getStatus().getStatusMessage();
if (message == null || message.isEmpty()) {
Toast.makeText(this, "Login failed", Toast.LENGTH_LONG).show();
}
new AlertDialog.Builder(this).setMessage(message)
.setNeutralButton(android.R.string.ok, null).show();
}
}
This the result of the log in the function onActivityResult()
0 | Intent { (has extras) } || 2 ||| 2
After I select an account of the the pop-up where I can choose my account. I get this screen with ok but when I have that the login already failed. See photo:
