Gplus user authentication and getting user location in the same action

In my activity, I implement the classes below

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 are designed to authenticate the user through google plus .

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

, and they are designed to get the user's current location

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

The methods in these classes are the same.

@Override
public void onConnected(Bundle connectionHint) {}

and

@Override
public void onConnectionFailed(ConnectionResult connectionResult) {}

Since these methods have the same parameters and the same return type, I cannot have two in the same class. So I think I need to determine which interface is being called from the Bundle or ConnectionResult . How can i do this? I mean, what key value do I need to check? If you need any clarification, please comment. Thanks you

+4
1

anonymous?

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
                }
            };
}
+2

Source: https://habr.com/ru/post/1538753/


All Articles