【问题标题】:GoogleApiClient.ConnectionCallbacks methods not called after connecting to the GoogleApiClient连接到 GoogleApiClient 后未调用 GoogleApiClient.ConnectionCallbacks 方法
【发布时间】:2015-06-05 10:22:11
【问题描述】:

我有这个问题:

GoogleApiClient.ConnectionCallbacks methods not being called after connecting to the GoogleApiClient

但是已经添加了回调,但仍然没有 onConnection 回调并且没有错误,为什么会这样?有人可以帮忙吗?

我的代码:

公共类 MainActivity 扩展 Activity 实现 GoogleApiClient.ConnectionCallbacks、GoogleApiClient.OnConnectionFailedListener { 私有 GoogleApiClient mGoogleApiClient ;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    initGoogleApiClient();
}

private void initGoogleApiClient() {
       mGoogleApiClient = new GoogleApiClient.Builder( this )
       .addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN)
       .addApi(Games.API).addScope(Games.SCOPE_GAMES)
       .addConnectionCallbacks(this)
       .addOnConnectionFailedListener(this)
       .build();

       mGoogleApiClient.connect();    
}
@Override
public void onConnected(Bundle bundle) {
}

@Override
public void onConnectionSuspended(int i) {
}

@Override
protected void onDestroy() {
    super.onDestroy();
    mGoogleApiClient.disconnect();
}

@Override
public void onConnectionFailed(com.google.android.gms.common.ConnectionResult connectionResult) {
}

【问题讨论】:

    标签: google-play-services


    【解决方案1】:

    【讨论】:

    • 好的,所以它仍然不起作用。有人能告诉我我必须在成就工作之前“发布”成就吗?
    • 我在开发者控制台中注册了登录信息,但由于未配置应用程序,我没有获得 onConnection?!我使用的电子邮件帐户被设置为测试人员帐户。为什么这现在不起作用?救命!
    【解决方案2】:

    没关系,我做到了!显然,您不能只从 Eclipse 调试您的应用程序,您必须使用 APK 安装它,否则它将无法工作。如此处所述:

    https://developers.google.com/games/services/android/quickstart

    祝所有阅读所有精彩 Google 文档的其他人好运。

    :-S

    【讨论】:

      猜你喜欢
      • 2015-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多