gpt4 book ai didi

java - Google Play 游戏服务登录失败

转载 作者:行者123 更新时间:2023-12-01 13:18:41 27 4
gpt4 key购买 nike

发生的事情非常奇怪。
每当用户启动登录时,都会出现“选择帐户” View ,选择帐户并单击“确定”后,将再次启动登录并返回相同的 View 。点击取消返回游戏登录失败,为什么会出现这种情况?

在启动登录之前,LogCat 中会出现以下内容:

03-06 13:53:06.797: D/PhoneWindow(2967): couldn't save which view has focus    
because the focused view org.cocos2dx.lib.Cocos2dxGLSurfaceView@40537408 has no id.

我是这样实现的:

public class myapp extends BaseGameActivity {
...
static Context mContext;
boolean mInSignInFlow = false;
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
mContext = myapp.this;
if(GooglePlayServicesUtil.isGooglePlayServicesAvailable (mContext) == ConnectionResult.SUCCESS){
GoogleApiClient.Builder builder =
new GoogleApiClient.Builder(this);
builder.addApi(Games.API)
.addScope(Games.SCOPE_GAMES);
mClient = builder.build();

}
}

@Override
protected void onStart() {
super.onStart();
if (!mInSignInFlow) {
// auto sign in
mClient.connect();
}
}
@Override
public void onSignInFailed() {
Log.w("Sign In", "Failed");
}

@Override
public void onSignInSucceeded() {
mInSignInFlow = true;
Log.w("Sign In", "Success");
}

public static void gameServicesSignIn() {
((myapp)mContext).runOnUiThread(new Runnable() {
public void run() {
((myapp)mContext).beginUserInitiatedSignIn();
}
});
}

当通过按钮单击调用 gameServicesSignIn() 时,我在启动时收到“登录失败”登录以及上面描述的情况。

最佳答案

看来您的构建不正确。通过查看流程(如果您扩展 BaseGameActivity),Helper 的底层设置已经为您处理好了。

来自 BaseGameActivity

public GameHelper getGameHelper() {
if (mHelper == null) {
mHelper = new GameHelper(this, mRequestedClients);
mHelper.enableDebugLog(mDebugLog);
}
return mHelper;
}

@Override
protected void onCreate(Bundle b) {
super.onCreate(b);
if (mHelper == null) {
getGameHelper();
}
mHelper.setup(this);
}

这还将负责设置监听器以调用您的 onSignInFailed/Succeded。

我在您的代码中看到的设置内容是在您不扩展 BaseGameActivity 时使用的。

关于java - Google Play 游戏服务登录失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22233501/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com