I see in their documentation where they clearly instruct you to include this import:
import com.google.android.gms.common.GooglePlayServicesClient.ConnectionCallbacks;
However, the error being thrown is expecting a different class than GooglePlayServicesClient.ConnectionCallbacks
, it's asking for GoogleApiClient.ConnectionCallbacks
. Try changing your implements to use the more-qualified class name. That looks to be the only possible thing throwing the code for a loop and without the explicit qualified classname, it will default to the directly imported class name.
It's always tougher when you have to question the manual.
Edit: I mean a change like this:
public class MainActivity
extends ActionBarActivity
implements GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener {
I too faced the same problem, i resolved by doing the following things.
import the right ConnectionCallbacks.
here is my code:
import android.content.Context;
import android.os.Bundle;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.drive.Drive;
public class GplusLogin implements
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener {
GoogleApiClient mGoogleApiClient;
GplusLogin(Context context){
mGoogleApiClient = new GoogleApiClient.Builder(context)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addConnectionCallbacks((GoogleApiClient.ConnectionCallbacks) context)
.addOnConnectionFailedListener(this)
.build();
}
@Override
public void onConnected(Bundle bundle) {
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
}
@Override
public void onConnectionSuspended(int i) {
}
}
turns out they (google) don't follow much of the guide themselves. Use their Google Drive Android Quickstart as a reference, which they actually do mention at the top of the tutorial, but they give it the misleading name "Android Quickstart" even though it is specific to Google Drive
The note at the top of the guide:
click alt enter and force android studio to implement:
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With