@Override **//depricated**
public void onActivityResult(int requestCode, int resultCode, @Nullable @org.jetbrains.annotations.Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
if (requestCode == REQUEST_OAUTH_REQUEST_CODE) {
insertAndVerifySession();
}
}
}
GoogleSignIn.requestPermissions(
fragment,
REQUEST_OAUTH_REQUEST_CODE,
GoogleSignIn.getLastSignedInAccount(context),
fitnessOptions);
What's the alternative of onActivityResult for GoogleSignIn in Fragment?
As here said, you can get sign in intent by calling getSignInIntent
ActivityResultLauncher<Intent> exampleActivityResult= registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(),
new ActivityResultCallback<ActivityResult>() {
@Override
public void onActivityResult(ActivityResult result) {
if (result.getResultCode() == Activity.RESULT_OK) {
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(result.getData());
handleSignInResult(task);
}
}
});
//call
exampleActivityResult.launch(mGoogleSignInClient.getSignInIntent());
Update - 30-11-2021
here is the new method by google !