【发布时间】: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) {
}
【问题讨论】: