Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在游戏服务上显示欢迎弹出窗口?_Android_Google Play Services_Google Play Games - Fatal编程技术网

Android 如何在游戏服务上显示欢迎弹出窗口?

Android 如何在游戏服务上显示欢迎弹出窗口?,android,google-play-services,google-play-games,Android,Google Play Services,Google Play Games,我在我的游戏上实现google play游戏服务。我可以连接它,但当我回到我的游戏,我不能显示欢迎弹出。。。我怎样才能展示它 我尝试了setviewforpopup和setgravityforpopus,就像他们在文档中说的那样 private void startSignInIntent() { GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN

我在我的游戏上实现google play游戏服务。我可以连接它,但当我回到我的游戏,我不能显示欢迎弹出。。。我怎样才能展示它

我尝试了setviewforpopup和setgravityforpopus,就像他们在文档中说的那样

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();
        }
    }
}

我实现了静默登录,在decorView上使用SetViewFor弹出窗口,只有当应用程序关闭很长时间(约10小时工作,不确定是否更少)时,欢迎返回才会显示。每次弹出窗口都显示交互式登录。

欢迎返回:

Games.getGamesClient(这个,googleSignInAccount)。setGravityForPopups(Gravity.TOP | Gravity.CENTER(水平))

要显示“欢迎回来”弹出窗口,请在登录成功时调用此方法

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

GamesClient client = Games.getGamesClient(mContext, signedInAccount);
client.setViewForPopups(vgContent);
client.setGravityForPopups(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
欢迎回来对话框将出现在屏幕顶部。 您可以提供上下文或活动


您需要提供一个弹出窗口的视图。在这里,我给出了活动的内容视图,它始终存在。

您遇到了什么错误?我没有错误,但没有弹出窗口。。。我不知道如何显示欢迎弹出窗口…你解决过这个问题吗,有相同的问题吗