Abdenaceur Lichiheb Abdenaceur Lichiheb - 9 months ago 45
Android Question

Android : Google API inside a custom adapter

I'm using a custom adapter called CustomQuestionAdapter, to display a list of question inside a listview, as we know the adapter extends from an ArrayAdapter, then i needed info about my location inside the adapter so i implemented the needed interfaces ( GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener ) and implemented it's methods, however it show me an error saying "method does not override method from its superclass" in the Overrided methods onStart() and onStop() , but when i tried to extends from AppCompatActivity instead of ArrayAdapter the error disappear.

This is the signature of my class :

public class CustomQuestionAdapter extends ArrayAdapter<Question> implements
GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener

Error here "method does not override method from its superclass"

protected void onStart() {

protected void onStop() {
if (mGoogleApiClient.isConnected()) {

So how to fix this properly ?

Isj Isj

For implementing GoogleApiClient.ConnectionCallbacks and GoogleApiClient.OnConnectionFailedListener, you have to override these methods

public void onConnected(@Nullable Bundle bundle) {


public void onConnectionSuspended(int i) {

    Log.d("isj","connection susspended");

public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {

    Log.d("isj","connection failed");

EDIT: onStart() and onStop() methods dont belong to the arrayAdapter class. Connect the google api client in the constructor of your adapter or you could create two methods to connect and disconnect the googleApiClient and call them from the activity in which you are setting the adapter.