My Situation:
- First, I implemented Google Plus authentication in my app. I followed the quick start instructions and added the quick start sample app code to my app.
- Then I wanted to obtain the user's last known location. The Fused Location Provider appeared to be the most modern way of obtaining it, so I looked at LocationUpdates.zip and kpbird's demo code.
My Concern:
The
com.google.android.gms.common.api.GoogleApiClient
andcom.google.android.gms.common.GooglePlayServicesClient
namespaces introduce some overlap by virtue of the fact that if you want to useGoogleApiClient
andLocationClient
, then your class (i.e.Activity
) must implement the following:GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, GooglePlayServicesClient.ConnectionCallbacks, GooglePlayServicesClient.OnConnectionFailedListener
And code from both namespaces will override the following:
@Override
public void onConnected(Bundle connectionHint) {
/* pseudo-code
if (GoogleApiClient) {
// Implementation
} else {
// Must be LocationClient
}
*/
}
@Override
public void onConnectionFailed(ConnectionResult result) {
/* pseudo-code
if (GoogleApiClient) {
// Implementation
} else {
// Must be LocationClient
}
*/
}
Such that you will be forced to write code to discern if it was the GoogleApiClient
or the LocationClient
that triggered the onConnected
and the onConnectionFailed
event handlers.
My Question:
- I'd like to preserve a separation of concerns. Is there a better way of going about this?