From the following code, in the if (resultCode == RESULT_OK && data!=null)
block you need to get the phone number in the variable credential
, here I am setting the phone number in a textfield userMobileNo
you can do any other operation as per your requirement.
And in the else
part when no hints are available you can request focus on the textfield where the user has to enter the mobile number.
Note: I have written the code in Kotlin but it will be automatically generated into Java in Android Studio
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RESOLVE_HINT) {
if (resultCode == RESULT_OK && data!=null) {
val credential = data.getParcelableExtra<Credential>(Credential.EXTRA_KEY)
userMobileNo.setText(credential?.id?.substring(3))
}
else if (resultCode == CredentialsApi.ACTIVITY_RESULT_NO_HINTS_AVAILABLE) {
//if no hints available
}
}