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

The following examples show how to use com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener. 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: 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 #4
Source File: MainActivity.java    From android-google-accounts with Apache License 2.0 5 votes vote down vote up
/**
 * Construct a client using AutoManage functionality.
 */
protected synchronized void rebuildGoogleApiClient() {
    // When we build the GoogleApiClient we specify where connected and connection failed
    // callbacks should be returned, which Google APIs our app uses and which OAuth 2.0
    // scopes our app requests. When using enableAutoManage to register the failed connection
    // listener it will only be called back when auto-resolution attempts were not
    // successful or possible. A normal ConnectionFailedListener is also registered below to
    // notify the activity when it needs to stop making API calls.
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */,
                    0 /* googleApiClientId used when auto-managing multiple googleApiClients */,
                    this /* OnConnectionFailedListener */)
            .addConnectionCallbacks(this /* ConnectionCallbacks */)
            // Register a connection listener that will notify on disconnect (including ones
            // caused by calling disconnect on the GoogleApiClient).
            .addOnConnectionFailedListener(new OnConnectionFailedListener() {
                @Override
                public void onConnectionFailed(ConnectionResult connectionResult) {
                    googleApiClientConnectionStateChange(true);
                }
            })
            .addApi(Plus.API)
            .addScope(new Scope(Scopes.PLUS_ME))
                    // TODO(developer): Specify any additional API Scopes or APIs you need here.
                    // The GoogleApiClient will ensure these APIs are available, and the Scopes
                    // are approved before invoking the onConnected callbacks.
            .build();
}
 
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();
	
}