Google Play游戏弹出连接消息未显示
您好,我有一个与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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您返回的任务应该在其中存储一个错误,以提供更多有关错误的详细信息。
您可以尝试这样的事情:
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 :
getException()
gives you a throwable i.e. something that gives you all the errors.