【发布时间】:2017-07-11 17:01:13
【问题描述】:
我想在 Google Play 游戏连接成功后开始一项活动。我尝试在 onConnected 方法、onConnectionSuspended 方法甚至 onConnectionFailed 中启动活动。活动不会开始。然后我在 onConnected 方法中放置了一个断点并调试了我的应用程序。即使 Google Play 游戏连接成功,该线程也没有暂停。 这些是我连接到 Google Play 游戏的方法。
@Override
protected void onStart() {
super.onStart();
mGoogleApiClient.connect();
}
@Override
public void onConnected(@Nullable Bundle bundle) {
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
if (connectionResult.hasResolution()){
try{
connectionResult.startResolutionForResult(this, 0);
}catch (IntentSender.SendIntentException e){
mGoogleApiClient.connect();
}
}
}
这是我的 Google Api 客户端代码。
mGoogleApiClient = new GoogleApiClient.Builder(this).addOnConnectionFailedListener(this)
.addApi(Plus.API, Plus.PlusOptions.builder().build()).addScope(Plus.SCOPE_PLUS_LOGIN)
.addApi(Games.API).addScope(Games.SCOPE_GAMES).build();
我做错了吗?我错过了什么吗?谢谢。
【问题讨论】:
-
The thread wasn't suspended even though Google Play Games was connected succesfully你怎么知道它连接了?我认为这就是问题所在。 -
嗯,我知道它已连接,但 android 没有。我希望 android 知道它已连接,以便我可以开始活动。
标签: java android google-api-client