Java Code Examples for com.google.android.gms.common.api.GoogleApiClient

The following examples show how to use com.google.android.gms.common.api.GoogleApiClient. These examples are extracted from open source projects. 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 Project: social-app-android   Source File: GoogleApiHelper.java    License: Apache License 2.0 6 votes vote down vote up
public static GoogleApiClient createGoogleApiClient(FragmentActivity fragmentActivity) {
    GoogleApiClient.OnConnectionFailedListener failedListener;

    if (fragmentActivity instanceof GoogleApiClient.OnConnectionFailedListener) {
        failedListener = (GoogleApiClient.OnConnectionFailedListener) fragmentActivity;
    } else {
        throw new IllegalArgumentException(fragmentActivity.getClass().getSimpleName() + " should implement OnConnectionFailedListener");
    }

    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(fragmentActivity.getResources().getString(R.string.google_web_client_id))
            .requestEmail()
            .build();

    return new GoogleApiClient.Builder(fragmentActivity)
            .enableAutoManage(fragmentActivity, failedListener)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();
}
 
Example 2
Source Project: android-Geofencing   Source File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Rather than displayng this activity, simply display a toast indicating that the geofence
    // service is being created. This should happen in less than a second.
    if (!isGooglePlayServicesAvailable()) {
        Log.e(TAG, "Google Play services unavailable.");
        finish();
        return;
    }

    mApiClient = new GoogleApiClient.Builder(this)
            .addApi(LocationServices.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

    mApiClient.connect();

    // Instantiate a new geofence storage area.
    mGeofenceStorage = new SimpleGeofenceStore(this);
    // Instantiate the current List of geofences.
    mGeofenceList = new ArrayList<Geofence>();
    createGeofences();
}
 
Example 3
Source Project: io2015-codelabs   Source File: UtilityService.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Add geofences using Play Services
 */
private void addGeofencesInternal() {
    Log.v(TAG, ACTION_ADD_GEOFENCES);
    GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
            .addApi(LocationServices.API)
            .build();

    // It's OK to use blockingConnect() here as we are running in an
    // IntentService that executes work on a separate (background) thread.
    ConnectionResult connectionResult = googleApiClient.blockingConnect(
            Constants.GOOGLE_API_CLIENT_TIMEOUT_S, TimeUnit.SECONDS);

    if (connectionResult.isSuccess() && googleApiClient.isConnected()) {
        PendingIntent pendingIntent = PendingIntent.getBroadcast(
                this, 0, new Intent(this, UtilityReceiver.class), 0);
        GeofencingApi.addGeofences(googleApiClient,
                TouristAttractions.getGeofenceList(), pendingIntent);
        googleApiClient.disconnect();
    } else {
        Log.e(TAG, String.format(Constants.GOOGLE_API_CLIENT_ERROR_MSG,
                connectionResult.getErrorCode()));
    }
}
 
Example 4
Source Project: android-Quiz   Source File: QuizReportActionService.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onHandleIntent(Intent intent) {
    if (intent.getAction().equals(ACTION_RESET_QUIZ)) {
        final GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
                .addApi(Wearable.API)
                .build();
        ConnectionResult result = googleApiClient.blockingConnect(CONNECT_TIMEOUT_MS,
                TimeUnit.MILLISECONDS);
        if (!result.isSuccess()) {
            Log.e(TAG, "QuizReportActionService failed to connect to GoogleApiClient.");
            return;
        }

        CapabilityApi.GetCapabilityResult capabilityResult = Wearable.CapabilityApi
                .getCapability(googleApiClient, RESET_QUIZ_CAPABILITY_NAME,
                        CapabilityApi.FILTER_REACHABLE)
                .await(GET_CAPABILITIES_TIMEOUT_MS, TimeUnit.MILLISECONDS);
        if (capabilityResult.getStatus().isSuccess()) {
            sendResetMessage(googleApiClient, capabilityResult.getCapability());
        } else {
            Log.e(TAG, "Failed to get capabilities, status: "
                    + capabilityResult.getStatus().getStatusMessage());
        }
    }
}
 
Example 5
Source Project: financisto   Source File: GoogleDriveClient.java    License: GNU General Public License v2.0 6 votes vote down vote up
private ConnectionResult connect() throws ImportExportException {
    if (googleApiClient == null) {
        String googleDriveAccount = MyPreferences.getGoogleDriveAccount(context);
        if (googleDriveAccount == null) {
            throw new ImportExportException(R.string.google_drive_account_required);
        }
        googleApiClient = new GoogleApiClient.Builder(context)
                .addApi(Drive.API)
                .addScope(Drive.SCOPE_FILE)
                .setAccountName(googleDriveAccount)
                //.addConnectionCallbacks(this)
                //.addOnConnectionFailedListener(this)
                .build();
    }
    return googleApiClient.blockingConnect(1, TimeUnit.MINUTES);
}
 
Example 6
Source Project: EasyFirebase   Source File: EasyFirebaseAuth.java    License: Apache License 2.0 6 votes vote down vote up
public EasyFirebaseAuth(GoogleApiClient googleApiClient) {
    mAuth = FirebaseAuth.getInstance();
    this.googleApiClient = googleApiClient;

    mAuthListener = new FirebaseAuth.AuthStateListener() {
        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
            final FirebaseUser user = firebaseAuth.getCurrentUser();
            if (user != null) {
                if (firebaseUserSubscriber != null) {
                    firebaseUserSubscriber.onNext(new Pair<GoogleSignInAccount, FirebaseUser>(googleSignInAccount, user));
                    firebaseUserSubscriber.onCompleted();
                }
                if (loggedSubcriber != null) {
                    loggedSubcriber.onNext(user);
                }
                // User is signed in
                Log.d("TAG", "onAuthStateChanged:signed_in:" + user.getUid());
            } else {
                // User is signed out
                Log.d("TAG", "onAuthStateChanged:signed_out");
            }
        }
    };
}
 
Example 7
Source Project: attendee-checkin   Source File: BaseActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Google+ Sign in
    mApiClient = new GoogleApiClient.Builder(this)
            .addApi(Plus.API)
            .addScope(Plus.SCOPE_PLUS_LOGIN)
            .addScope(Plus.SCOPE_PLUS_PROFILE)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();
    mConnectionProgressDialog = new ProgressDialog(this);
    mConnectionProgressDialog.setMessage(getString(R.string.signing_in));
    GutenbergApplication app = GutenbergApplication.from(this);
    if (!app.isUserLoggedIn()) {
        selectAccount(false);
    } else {
        app.requestSync(false);
    }
    adjustTaskDescription();
}
 
Example 8
Source Project: AndroidProgramming3e   Source File: LocatrFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);

    mClient = new GoogleApiClient.Builder(getActivity()).addApi(LocationServices.API)
            .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
                @Override
                public void onConnected(@Nullable Bundle bundle) {
                    getActivity().invalidateOptionsMenu();
                }

                @Override
                public void onConnectionSuspended(int i) {

                }
            })
            .build();
}
 
Example 9
Source Project: wearabird   Source File: DeviceClient.java    License: MIT License 6 votes vote down vote up
public void sendSensorData(final int sensorType, final int accuracy, final long timestamp, final float[] values) {
	ConnectionManager.getInstance(context).sendMessage(new ConnectionManager.ConnectionManagerRunnable(context) {
		@Override
		public void send(GoogleApiClient googleApiClient) {
			PutDataMapRequest dataMap = PutDataMapRequest.create("/sensors/" + sensorType);

			dataMap.getDataMap().putInt(DataMapKeys.ACCURACY, accuracy);
			dataMap.getDataMap().putLong(DataMapKeys.TIMESTAMP, timestamp);
			dataMap.getDataMap().putFloatArray(DataMapKeys.VALUES, values);

			PutDataRequest putDataRequest = dataMap.asPutDataRequest();

			Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
		}
	});
}
 
Example 10
private synchronized void buildGoogleApiClient() {
    googleApiClient = new GoogleApiClient.Builder(getActivity())
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(LocationServices.API)
            .build();
}
 
Example 11
Source Project: braintree_android   Source File: BraintreeFragmentTest.java    License: MIT License 5 votes vote down vote up
@Test(timeout = 6000)
public void getGoogleApiClient_returnsGoogleApiClient() throws InterruptedException {
    BraintreeFragment fragment = getFragmentWithAuthorization(mActivity, mClientToken);

    fragment.getGoogleApiClient(new BraintreeResponseListener<GoogleApiClient>() {
        @Override
        public void onResponse(GoogleApiClient googleApiClient) {
            assertNotNull(googleApiClient);
            mCountDownLatch.countDown();
        }
    });

    mCountDownLatch.await();
}
 
Example 12
Source Project: LibreAlarm   Source File: WearService.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    setupTextToSpeech();
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Wearable.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();
    mGoogleApiClient.connect();
}
 
Example 13
Source Project: friendspell   Source File: GoogleApiClientBridge.java    License: Apache License 2.0 5 votes vote down vote up
public void unsubscribe(String token, MessageListener listener, ResultCallback<Status> callback) {
  GoogleApiClient googleApiClient = clients.get(token);
  if (googleApiClient.isConnected()) {
    Nearby.Messages.unsubscribe(googleApiClient, listener)
        .setResultCallback(callback);
  }
}
 
Example 14
Source Project: ExamplesAndroid   Source File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
protected synchronized void buildGoogleApiClient() {
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(LocationServices.API)
            .build();
    mGoogleApiClient.connect();


}
 
Example 15
Source Project: wear-os-samples   Source File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get a list of all wearable nodes that are connected synchronously.
 * Only call this method from a background thread (it should never be
 * called from the main/UI thread as it blocks).
 */
public static Collection<String> getNodes(GoogleApiClient client) {
    Collection<String> results= new HashSet<String>();
    NodeApi.GetConnectedNodesResult nodes =
            Wearable.NodeApi.getConnectedNodes(client).await();
    for (Node node : nodes.getNodes()) {
        results.add(node.getId());
    }
    return results;
}
 
Example 16
Source Project: io.appium.settings   Source File: LocationService.java    License: Apache License 2.0 5 votes vote down vote up
private FusedLocationProvider createFusedLocationProvider() {
    GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
            .addApi(LocationServices.API)
            .build();
    FusedLocationProviderClient locationProviderClient = LocationServices.getFusedLocationProviderClient(this);
    return new FusedLocationProvider(googleApiClient, locationProviderClient, this);
}
 
Example 17
Source Project: Trivia-Knowledge   Source File: SnapshotCoordinator.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public PendingResult<OpenSnapshotResult> resolveConflict(GoogleApiClient googleApiClient,
                                                         String conflictId,
                                                         final Snapshot snapshot) {
    if (!isAlreadyOpen(snapshot.getMetadata().getUniqueName()) &&
            !isAlreadyClosing(snapshot.getMetadata().getUniqueName())) {
        setIsOpening(snapshot.getMetadata().getUniqueName());
        try {
            return new CoordinatedPendingResult<>(
                    Games.Snapshots.resolveConflict(googleApiClient, conflictId, snapshot),
                    new ResultListener() {
                        @Override
                        public void onResult(Result result) {
                            if (!result.getStatus().isSuccess()) {
                                setClosed(snapshot.getMetadata().getUniqueName());
                            }
                        }
                    });
        } catch (RuntimeException e) {
            setClosed(snapshot.getMetadata().getUniqueName());
            throw e;
        }
    } else {
        throw new IllegalStateException(snapshot.getMetadata().getUniqueName() +
                " is already open or is busy");
    }
}
 
Example 18
Source Project: flopsydroid   Source File: MyActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my);

    mBtnOnWearable = (ImageView) findViewById(R.id.startWearable);
    mBtnOnWearable.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            getNodes(new OnGotNodesListener() {
                @Override
                public void onGotNodes(ArrayList<String> nodes) {
                    if(nodes.size() > 0) {
                        Wearable.MessageApi.sendMessage(
                                getGoogleApiClient(), nodes.get(0), "/flopsydroid/wear", null).setResultCallback(new ResultCallback<MessageApi.SendMessageResult>() {
                            @Override
                            public void onResult(MessageApi.SendMessageResult result) {
                                if (!result.getStatus().isSuccess()) {
                                }
                            }
                        });
                    }
                }
            });
        }
    });

    mGoogleAppiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(Wearable.API)
            .build();
}
 
Example 19
Source Project: io2015-codelabs   Source File: UtilityService.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sends the actual message to ask other devices that are capable of showing "details" to start
 * the appropriate activity
 *
 * @param path the path to pass to the wearable message API
 * @param extraInfo extra info that varies based on the path being sent
 */
private void startDeviceActivityInternal(String path, String extraInfo) {
    GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Wearable.API)
            .build();

    ConnectionResult connectionResult = googleApiClient.blockingConnect(
            Constants.GOOGLE_API_CLIENT_TIMEOUT_S, TimeUnit.SECONDS);

    if (connectionResult.isSuccess() && googleApiClient.isConnected()) {
        CapabilityApi.GetCapabilityResult result = Wearable.CapabilityApi.getCapability(
                googleApiClient,
                getApplicationContext().getString(R.string.show_detail_capability_name),
                CapabilityApi.FILTER_REACHABLE)
                .await(GET_CAPABILITY_TIMEOUT_S, TimeUnit.SECONDS);
        if (result.getStatus().isSuccess()) {
            Set<Node> nodes = result.getCapability().getNodes();
            for (Node node : nodes) {
                Wearable.MessageApi.sendMessage(
                        googleApiClient, node.getId(), path, extraInfo.getBytes());
            }
        } else {
            Log.e(TAG, "startDeviceActivityInternal() Failed to get capabilities, status: "
                    + result.getStatus().getStatusMessage());
        }

        googleApiClient.disconnect();
    }
}
 
Example 20
Source Project: Onesearch   Source File: GameHelper.java    License: MIT License 5 votes vote down vote up
/**
 * Creates a GoogleApiClient.Builder for use with @link{#setup}. Normally,
 * you do not have to do this; use this method only if you need to make
 * nonstandard setup (e.g. adding extra scopes for other APIs) on the
 * GoogleApiClient.Builder before calling @link{#setup}.
 */
public GoogleApiClient.Builder createApiClientBuilder() {
    if (mSetupDone) {
        String error = "GameHelper: you called GameHelper.createApiClientBuilder() after "
                + "calling setup. You can only get a client builder BEFORE performing setup.";
        logError(error);
        throw new IllegalStateException(error);
    }

    GoogleApiClient.Builder builder = new GoogleApiClient.Builder(
            mActivity, this, this);

    if (0 != (mRequestedClients & CLIENT_GAMES)) {
        builder.addApi(Games.API, mGamesApiOptions);
        builder.addScope(Games.SCOPE_GAMES);
    }

    if (0 != (mRequestedClients & CLIENT_PLUS)) {
        builder.addApi(Plus.API);
        builder.addScope(Plus.SCOPE_PLUS_LOGIN);
    }

    if (0 != (mRequestedClients & CLIENT_APPSTATE)) {
        builder.addApi(AppStateManager.API);
        builder.addScope(AppStateManager.SCOPE_APP_STATE);
    }

    if (0 != (mRequestedClients & CLIENT_SNAPSHOT)) {
      builder.addScope(Drive.SCOPE_APPFOLDER);
      builder.addApi(Drive.API);
    }

    mGoogleApiClientBuilder = builder;
    return builder;
}
 
Example 21
Source Project: ETSMobile-Android2   Source File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
private String getRemoteNodeId(GoogleApiClient googleApiClient) {
    NodeApi.GetConnectedNodesResult nodesResult =
            Wearable.NodeApi.getConnectedNodes(googleApiClient).await();
    List<Node> nodes = nodesResult.getNodes();
    if (nodes.size() > 0) {
        return nodes.get(0).getId();
    }
    return null;
}
 
Example 22
Source Project: arcgis-runtime-demos-android   Source File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void initGoogleApiClient() {
  mGoogleApiClient = new GoogleApiClient.Builder(MainActivity.this)
          .addApi(Wearable.API)
          .addConnectionCallbacks(new WearConnectionCallbacks())
          .addOnConnectionFailedListener(new WearConnectionFailedListener())
          .build();
  mGoogleApiClient.connect();
}
 
Example 23
private synchronized void buildGoogleApiClient(@NonNull Context context) {
    mGoogleApiClient = new GoogleApiClient.Builder(context.getApplicationContext())         // Use getApplicationContext to prevent memory leak: https://stackoverflow.com/questions/35308231/memory-leak-with-googleapiclient-detected-by-android-studio
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(LocationServices.API)
            .build();
}
 
Example 24
Source Project: journaldev   Source File: SecondActivity.java    License: MIT License 5 votes vote down vote up
public void setUpGoogleApiClient() {

        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addApi(Auth.CREDENTIALS_API)
                .enableAutoManage(this, this)
                .build();
    }
 
Example 25
Source Project: andela-med-manager   Source File: AuthActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_auth);
    ButterKnife.bind(this);

    addUserViewModel = ViewModelProviders.of(this).get(AddUserViewModel.class);

    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .build();

    // Build a GoogleApiClient with access to the Google Sign-In Api and the
    // options specified by gso.
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivitgit y */, this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();

    loginButton.setOnClickListener(v -> {
        //Check Internet Connection
        //  if (NetworkUtil.isConnected(this))
        googleSignIn();

    });
}
 
Example 26
@Override
public ApiConnection build(Context context, Looper looper,
        Api.ApiOptions.NoOptions options,
        AccountInfo accountInfo, GoogleApiClient.ConnectionCallbacks callbacks,
        GoogleApiClient.OnConnectionFailedListener connectionFailedListener) {
    return new LocationClientImpl(context, callbacks, connectionFailedListener);
}
 
Example 27
Source Project: firebase-android-sdk   Source File: DynamicLinksClient.java    License: Apache License 2.0 5 votes vote down vote up
public DynamicLinksClient(
    Context context,
    Looper looper,
    ClientSettings clientSettings,
    GoogleApiClient.ConnectionCallbacks connectedListener,
    GoogleApiClient.OnConnectionFailedListener connectionFailedListener) {
  super(
      context,
      looper,
      // ServiceId.DYNAMIC_LINKS_API_VALUE,
      131,
      clientSettings,
      connectedListener,
      connectionFailedListener);
}
 
Example 28
Source Project: social-app-android   Source File: LogoutHelper.java    License: Apache License 2.0 5 votes vote down vote up
private static void logoutByProvider(String providerId, GoogleApiClient mGoogleApiClient, FragmentActivity fragmentActivity) {
    switch (providerId) {
        case GoogleAuthProvider.PROVIDER_ID:
            logoutGoogle(mGoogleApiClient, fragmentActivity);
            break;

        case FacebookAuthProvider.PROVIDER_ID:
            logoutFacebook(fragmentActivity.getApplicationContext());
            break;
    }
}
 
Example 29
Source Project: AndroidWearable-Samples   Source File: SetTimerActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    int paramLength = getIntent().getIntExtra(AlarmClock.EXTRA_LENGTH, 0);
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "SetTimerActivity:onCreate=" + paramLength);
    }
    if (paramLength > 0 && paramLength <= 86400) {
        long durationMillis = paramLength * 1000;
        setupTimer(durationMillis);
        finish();
        return;
    }

    Resources res = getResources();
    for (int i = 0; i < NUMBER_OF_TIMES; i++) {
        mTimeOptions[i] = new ListViewItem(
                res.getQuantityString(R.plurals.timer_minutes, i + 1, i + 1),
                (i + 1) * 60 * 1000);
    }

    setContentView(R.layout.timer_set_timer);

    // Initialize a simple list of countdown time options.
    mListView = (ListView) findViewById(R.id.times_list_view);
    ArrayAdapter<ListViewItem> arrayAdapter = new ArrayAdapter<ListViewItem>(this,
            android.R.layout.simple_list_item_1, mTimeOptions);
    mListView.setAdapter(arrayAdapter);
    mListView.setOnItemClickListener(this);

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Wearable.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();
}
 
Example 30
Source Project: friendlyping   Source File: RegistrationIntentService.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sends the registration to the server.
 *
 * @param token The token to send.
 * @throws IOException Thrown when a connection issue occurs.
 */
private void sendRegistrationToServer(String token) throws IOException {
    final GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Plus.API)
            .addScope(Plus.SCOPE_PLUS_PROFILE)
            .build();
    googleApiClient.blockingConnect();

    Bundle registration = createRegistrationBundle(googleApiClient);
    registration.putString(PingerKeys.REGISTRATION_TOKEN, token);

    // Register the user at the server.
    GoogleCloudMessaging.getInstance(this).send(FriendlyPingUtil.getServerUrl(this),
            String.valueOf(System.currentTimeMillis()), registration);
}