Google Play游戏弹出连接消息未显示

发布于 2025-01-21 11:39:19 字数 1673 浏览 1 评论 0原文

您好,我有一个与V2 SDK一起使用Google Play游戏服务的游戏应用程序,问题在于用户是通过游戏服务自动连接的,但是弹出消息表示未显示用户连接的用户。例如: https://i.sstatic.net/y3sxxv.png

调用API的代码:

    public static ScalingData data;
    private GamesSignInClient gamesSignInClient = PlayGames.getGamesSignInClient(this);
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        PlayGamesSdk.initialize(this);
        init();
        gamesSignInClient.isAuthenticated().addOnCompleteListener(isAuthenticatedTask -> {
            boolean isAuthenticated =
                    (isAuthenticatedTask.isSuccessful() &&
                            isAuthenticatedTask.getResult().isAuthenticated());

            TextView v = findViewById(R.id.textView);
            if (isAuthenticated) {
                PlayGames.getPlayersClient(this).getCurrentPlayer().addOnCompleteListener(mTask -> {
                            v.setText(mTask.getResult().getDisplayName());
                        }
                );
            } else {
                v.setText("User not authenticated");
            }
        });

    }

    private void init(){
        setContentView(R.layout.activity_main);
        DisplayMetrics metrics = getResources().getDisplayMetrics();
        data = new ScalingData(new Dimension(metrics.widthPixels,metrics.heightPixels));
        try {
            Game g = new Game(this);
            KeyboardManager k = new KeyboardManager(g);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

Hello I have a game application that use Google play games services with the V2 Sdk, the problem is that the user is automatically connected through the games services but the pop-up message saying that the user is connected is not showing. Like this for example : https://i.sstatic.net/y3sXV.png

here my code calling the API :

    public static ScalingData data;
    private GamesSignInClient gamesSignInClient = PlayGames.getGamesSignInClient(this);
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        PlayGamesSdk.initialize(this);
        init();
        gamesSignInClient.isAuthenticated().addOnCompleteListener(isAuthenticatedTask -> {
            boolean isAuthenticated =
                    (isAuthenticatedTask.isSuccessful() &&
                            isAuthenticatedTask.getResult().isAuthenticated());

            TextView v = findViewById(R.id.textView);
            if (isAuthenticated) {
                PlayGames.getPlayersClient(this).getCurrentPlayer().addOnCompleteListener(mTask -> {
                            v.setText(mTask.getResult().getDisplayName());
                        }
                );
            } else {
                v.setText("User not authenticated");
            }
        });

    }

    private void init(){
        setContentView(R.layout.activity_main);
        DisplayMetrics metrics = getResources().getDisplayMetrics();
        data = new ScalingData(new Dimension(metrics.widthPixels,metrics.heightPixels));
        try {
            Game g = new Game(this);
            KeyboardManager k = new KeyboardManager(g);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

豆芽 2025-01-28 11:39:19

您返回的任务应该在其中存储一个错误,以提供更多有关错误的详细信息。

您可以尝试这样的事情:

Log.e("Connection", "Unable to connect", isAuthenticatedTask.getException());

getException()为您提供了可抛出的东西,即给您所有错误。

The task you're getting back should have an error stored in it that gives more detail on the error.

You can try something like this :

Log.e("Connection", "Unable to connect", isAuthenticatedTask.getException());

getException() gives you a throwable i.e. something that gives you all the errors.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文