com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks Java Examples

The following examples show how to use com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DynamicLinksApi.java    From firebase-android-sdk with Apache License 2.0 5 votes vote down vote up
@Override
public DynamicLinksClient buildClient(
    Context context,
    Looper looper,
    ClientSettings commonSettings,
    NoOptions apiOptions,
    ConnectionCallbacks connectedListener,
    OnConnectionFailedListener connectionFailedListener) {
  return new DynamicLinksClient(
      context, looper, commonSettings, connectedListener, connectionFailedListener);
}
 
Example #2
Source File: LocationService.java    From go-bees with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Set location service listeners.
 *
 * @param connectionListener       ConnectionCallbacks.
 * @param connectionFailedListener OnConnectionFailedListener.
 */
void setListeners(ConnectionCallbacks connectionListener,
                  OnConnectionFailedListener connectionFailedListener) {
    // Create an instance of the Google Play services API client
    this.googleApiClient = new GoogleApiClient.Builder(context)
            .addConnectionCallbacks(connectionListener)
            .addOnConnectionFailedListener(connectionFailedListener)
            .addApi(LocationServices.API)
            .build();
}
 
Example #3
Source File: GoogleApiClientWrapper.java    From android-play-games-in-motion with Apache License 2.0 5 votes vote down vote up
@Override
public void onConnectionSuspended(int i) {
    // If your connection gets lost at some point,
    // you'll be able to determine the reason and react to it here.
    if (i == ConnectionCallbacks.CAUSE_NETWORK_LOST) {
        Utils.logDebug(TAG, "Connection lost.  Cause: Network Lost.");
    } else if (i == ConnectionCallbacks.CAUSE_SERVICE_DISCONNECTED) {
        Utils.logDebug(TAG, "Connection lost.  Reason: Service Disconnected");
    }
    // Send the hint to Activity for UI updates
    ((MainActivity) mActivity).onFitStatusUpdated(false);
    // Attempt to reconnect
    connect();
}
 
Example #4
Source File: BraintreeFragment.java    From braintree_android with MIT License 5 votes vote down vote up
protected GoogleApiClient getGoogleApiClient() {
    if (getActivity() == null) {
        postCallback(new GoogleApiClientException(ErrorType.NotAttachedToActivity, 1));
        return null;
    }

    if (mGoogleApiClient == null) {
        mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
                .addApi(Wallet.API, new Wallet.WalletOptions.Builder()
                        .setEnvironment(GooglePayment.getEnvironment(getConfiguration().getGooglePayment()))
                        .setTheme(WalletConstants.THEME_LIGHT)
                        .build())
                .build();
    }

    if (!mGoogleApiClient.isConnected() && !mGoogleApiClient.isConnecting()) {
        mGoogleApiClient.registerConnectionCallbacks(new ConnectionCallbacks() {
            @Override
            public void onConnected(Bundle bundle) {}

            @Override
            public void onConnectionSuspended(int i) {
                postCallback(new GoogleApiClientException(ErrorType.ConnectionSuspended, i));
            }
        });

        mGoogleApiClient.registerConnectionFailedListener(new OnConnectionFailedListener() {
            @Override
            public void onConnectionFailed(ConnectionResult connectionResult) {
                postCallback(new GoogleApiClientException(ErrorType.ConnectionFailed, connectionResult.getErrorCode()));
            }
        });

        mGoogleApiClient.connect();
    }

    return mGoogleApiClient;
}
 
Example #5
Source File: LoginActivity.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 5 votes vote down vote up
private void initGoogleApliClient(){
	
	googleAPIClient = new GoogleApiClient.Builder(this)
	.addConnectionCallbacks(
			(GoogleApiClient.ConnectionCallbacks) this)
	.addOnConnectionFailedListener(
			(GoogleApiClient.OnConnectionFailedListener) this)
	.addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN).build();
	
}