3

I implement the google play game services on my game. I can connect on it but when I come back to my game, I can't show the welcome POPUP ... How can I show it ?

I tried the setViewForPopups and setGravityForPopups like they said on the documentation...

private void startSignInIntent() {
 GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
            .requestEmail()
            .build();
GoogleSignInClient signInClient = GoogleSignIn.getClient(getActivity(),
            gso);
    Intent intent = signInClient.getSignInIntent();
    startActivityForResult(intent, RC_SIGN_IN);
}


@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    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();
            Games.getGamesClient(getContext(), signedInAccount).setViewForPopups(getView());
        } else {
            String message = result.getStatus().getStatusMessage();
            if (message == null || message.isEmpty()) {
                message = getString(R.string.signin_other_error);
            }
            new AlertDialog.Builder(getActivity()).setMessage(message)
                    .setNeutralButton(android.R.string.ok, null).show();
        }
    }
}
trunyk
  • 31
  • 4

3 Answers3

4

welcome back:

Games.getGamesClient(this, googleSignInAccount).setGravityForPopups(Gravity.TOP | Gravity.CENTER_HORIZONTAL);

2

In order to show the "Welcome Back" popup, call this method when sign-in is successful.

ViewGroup vgContent = activity.findViewById(R.id.content);

GamesClient client = Games.getGamesClient(mContext, signedInAccount);
client.setViewForPopups(vgContent);
client.setGravityForPopups(Gravity.TOP | Gravity.CENTER_HORIZONTAL);

Welcome back dialog is going to appear at the top of the screen. You can give either Context or Activity.

You will need to provide a view for a popup to appear. Here I am giving the activity's content view, which is always present.

amira
  • 416
  • 1
  • 7
  • 24
0

I implemented silent sign-in, used setViewForPopups on the decorView and the welcome back shows only if the app was off for a quiet long time (~10h worked, not sure about less).The pop-up shows each time with interactive sign-in.

xyod
  • 11
  • 1