连接到GoogleApiClient后未调用的GoogleApiClient.ConnectionCallbacks方法

时间:2015-06-05 10:22:12

标签: google-play-services

我有这个问题:

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

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

我的代码:

公共类MainActivity extends 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) {
}

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

没关系,我已经做到了!显然你不能只是从Eclipse调试你的应用程序你必须用APK安装它,否则它不会工作。如下所述:

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

祝其他人浏览所有精彩的Google文档,祝你好运。

: - S