4

In my activity i am implementing the below given classes

com.google.android.gms.common.GooglePlayServicesClient.ConnectionCallbacks,
com.google.android.gms.common.GooglePlayServicesClient.OnConnectionFailedListener,
com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks,
com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener

These two interfaces is for authenticating user through google plus.

com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks,
com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener

and these are for getting user current location

com.google.android.gms.common.GooglePlayServicesClient.ConnectionCallbacks,
com.google.android.gms.common.GooglePlayServicesClient.OnConnectionFailedListener

the methods have in these classes are same.

@Override
public void onConnected(Bundle connectionHint) {}

and

@Override
public void onConnectionFailed(ConnectionResult connectionResult) {}

Since these methods have the same parameters and same return type i cant have two in the same class. So i think i need to identify which interface have invoked from the Bundle or ConnectionResult . How i can do this ? I mean which key value i need to check ? If need any clarification please comment. Thank you

Kamalone
  • 4,045
  • 5
  • 40
  • 64
  • 1
    Go the answer from here http://stackoverflow.com/questions/2598009/method-name-collision-in-interface-implementation-java – Kamalone Apr 30 '14 at 16:58

1 Answers1

2

What about implementing the interfaces as a anonymous member declaration ?

public class Ac {

    private GooglePlayServicesClient.OnConnectionFailedListener psConnectionFailedListener =
            new GooglePlayServicesClient.OnConnectionFailedListener() {

                @Override
                public void onConnectionFailed(ConnectionResult connectionResult) {
                    // implementation
                }
            };

    private GooglePlayServicesClient.ConnectionCallbacks psConnectionCallbacks =
            new GooglePlayServicesClient.ConnectionCallbacks() {

                @Override
                public void onConnected(Bundle bundle) {
                    // implementation
                }

                @Override
                public void onDisconnected() {
                    // implementation
                }
            };

    private GoogleApiClient.ConnectionCallbacks googleConnectionCallbacks =
            new GoogleApiClient.ConnectionCallbacks() {

                @Override
                public void onConnected(Bundle bundle) {
                    // implementation
                }

                @Override
                public void onConnectionSuspended(int i) {
                    // implementation
                }
            };

    private GoogleApiClient.OnConnectionFailedListener googleConnectionFailedListener =
            new GoogleApiClient.OnConnectionFailedListener() {

                @Override
                public void onConnectionFailed(ConnectionResult connectionResult) {
                    // implementation
                }
            };
}
JafarKhQ
  • 8,676
  • 3
  • 35
  • 45