0

I have implemented Google sign-in in my application. When I tap the sign in with google button my screen is as the screenshot displayed below. Lists all accounts signed in my phone.Screenshot

Then I press my Home button and my app goes to background. After that when I select my app from background the same screen exists like in the screenshot. I want to dismiss this account chooser screen whenever i goes to background and then comes back. I want my Home activity screen to be displayed when I goes to background and comes back. Whats the solution for this friends?

EDITED : This is how the account picker is started ..

private void signInWithGoogle() {
    Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
    startActivityForResult(signInIntent, RC_SIGN_IN);
}

and the callback of this intent is received in

    @Override
protected 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);
        handleSignInResult(result);
    }
}

Edited 2 This is how I call the signInWithGoogle() method

            @Override
public void onClick(View view) {
        switch (view.getId()) {
            case R.id.signInWithGoogleBtn:
                isGsigninInProgress = true;
                signInWithGoogle();
                break;
        }
    }
}
Febin K R
  • 886
  • 2
  • 11
  • 21

1 Answers1

0
@Override
public void onResume(){
    super.onResume()
    if(google_picker.isShowing(){
        google_picker.dismiss()
    }
}

Whenever the app is resumed this will close your picker if it is open

MacLean Sochor
  • 435
  • 5
  • 14
  • The Google sign-in dialog is what I'm referring to when I say google_picker. At some point you have _variablename_.show() so the way to dismiss that same dialog is _variablename_.dismiss – MacLean Sochor Jun 12 '17 at 14:23
  • No @MacLean. No variables are used for account picker. Only an Intent is started. `Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient); startActivityForResult(signInIntent, RC_SIGN_IN);` And its result (also control) will be got back inside `onActivityResult(int requestCode, int resultCode, Intent data)`. So what to do? – Febin K R Jun 12 '17 at 14:42
  • You should edit your question and post all of the relevant code there to make it readable – MacLean Sochor Jun 12 '17 at 14:45