I need to pass a text-string along with the Google Sign-In Intent, so that I can retrieve it later in the onActivityResult
method.
I trigger the GSI account chooser activity with the following code
GoogleSignInOptions googleSignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken("xxxxxxxxxxxxxxxxxxxxx")
.requestEmail()
.build();
final GoogleSignInClient client = GoogleSignIn.getClient(MainActivity.activity, googleSignInOptions);
Intent signInIntent = client.getSignInIntent();
// As extra
signInIntent.putExtra("CALLSTACK_UID", newCallStack.uid);
this.startActivityForResult(signInIntent, RC_SIGN_IN);
and try to retrieve it later via
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
String callstack_uid = data.getStringExtra("CALLSTACK_UID");
//...
}
}
data.getStringExtra("CALLSTACK_UID")
is always returning null
, even when it should be returning a String.
Is my only option here to create a static variable in the activity instead of passing the value through the intent?
from How to pass extra data along with the Intent obtained from GoogleSignInClient.getSignInIntent()?
No comments:
Post a Comment