0

I have installed all the sdks(s) necessary and the GoogleAPI, Google Play Services etc. but I am still getting an error! Please note I am still in the initial steps of making the application, hence the lack of code, This is my code:

package com.example.googleapi;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.app.Activity;
import android.content.Intent;
import android.content.IntentSender;
import android.content.IntentSender.SendIntentException;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Log;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.drive.Drive;
import com.google.android.gms.drive.DriveApi.DriveContentsResult;
import com.google.android.gms.drive.MetadataChangeSet;



public class MainActivity extends ActionBarActivity {

    GoogleApiClient mGoogleApiClient;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addApi(Drive.API)
                .addScope(Drive.SCOPE_FILE)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .build();
    }

    @Override
    protected void onStart() {
        super.onStart();
        mGoogleApiClient.connect();
    }

}

This is the compile error I am getting:

Error:(38, 17) error: method addConnectionCallbacks in class Builder cannot be applied to given types;
required: ConnectionCallbacks
found: MainActivity
reason: actual argument MainActivity cannot be converted to ConnectionCallbacks by method invocation conversion
Ashwin Praveen
  • 661
  • 2
  • 10
  • 20

1 Answers1

0

Your MainActivity class need to implement following two interfaces: GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener. Also your class now need to implement/Override a couple of methods from those classes. So your MainActivity class should looks something similar to following:

public class MainActivity extends ActionBarActivity
        implements GoogleApiClient.ConnectionCallbacks
        ,GoogleApiClient.OnConnectionFailedListener

For GoogleApiClient visit this link: https://developers.google.com/android/reference/com/google/android/gms/common/api/GoogleApiClient

Renzo
  • 26,848
  • 5
  • 49
  • 61
Malik Khan
  • 74
  • 6