无法添加回调:无法转换为ConnectionCallbacks

时间:2015-06-20 18:44:57

标签: android google-api

我正在尝试使用googleApiClient

将回复添加回addConnectionCallbacks
mPlusClient  = new GoogleApiClient.Builder(this).addConnectionCallbacks(this).addOnConnectionFailedListener(this).addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN).build();

但是我收到了这个错误:

Error:(85, 81) error: incompatible types: PlusBaseActivity cannot be converted to ConnectionCallbacks

我从在线教程中获取此代码,但它似乎无法正常工作,请帮助。

2 个答案:

答案 0 :(得分:2)

我对您正在做的事情没有任何经验,但可能是PlusBaseActivity班级必须实施ConnectionCallbacks才能成为'回调?像:

public class PlusBaseActivity extends Activity implements ConnectionCallbacks{
// add ConnectionCallBack methods
}

答案 1 :(得分:0)

实施方法

@Override
public void onConnected(@Nullable Bundle bundle) {
   Log.i("LOG", "Conectado ao Google Play Services!");
}
@Override
public void onConnectionSuspended(int i) {
   Log.i("LOG", "Conexão Interrompida");
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
   Log.i("LOG", "Erro ao conectar: " + connectionResult);
}