use of com.google.android.gms.common.api.GoogleApiClient in project Memento-Calendar by alexstyl.
the class ContactEventsProviderService method onComplicationUpdate.
@Override
public void onComplicationUpdate(final int complicationId, final int dataType, final ComplicationManager complicationManager) {
GoogleApiClient.ConnectionCallbacks connectionCallbacks = new GoogleApiClient.ConnectionCallbacks() {
@Override
public void onConnected(@Nullable Bundle bundle) {
wearCommunicationService.loadDataItems(new WearCommunicationService.Callback() {
@Override
public void onDataItemsLoaded(DataItem item) {
ComplicationData complicationData = createComplicationData(item, dataType);
if (complicationData != null) {
complicationManager.updateComplicationData(complicationId, complicationData);
}
}
@Override
public void onNoDataItemsAvailable() {
ComplicationData emptyComplicationData = createComplicationData(dataType, NO_DATE_AVAILABLE, Collections.<String>emptyList());
complicationManager.updateComplicationData(complicationId, emptyComplicationData);
}
});
}
@Override
public void onConnectionSuspended(int i) {
// no-op
}
};
GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this).addApi(Wearable.API).addConnectionCallbacks(connectionCallbacks).build();
wearCommunicationService = new WearCommunicationService(googleApiClient);
googleApiClient.connect();
}
use of com.google.android.gms.common.api.GoogleApiClient in project Memento-Calendar by alexstyl.
the class WearSyncService method onHandleIntent.
@Override
protected void onHandleIntent(Intent intent) {
if (!permissions.canReadAndWriteContacts()) {
return;
}
Optional<ContactEventsOnADate> eventsOptional = fetchContactEvents();
if (eventsOptional.isPresent()) {
ContactEventsOnADate contactEvents = eventsOptional.get();
PutDataRequest putDataRequest = createDataRequest(contactEvents);
GoogleApiClient googleApiClient = new GoogleApiClient.Builder(getApplicationContext()).addApi(Wearable.API).build();
if (googleApiClient.blockingConnect().isSuccess()) {
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
}
}
}
use of com.google.android.gms.common.api.GoogleApiClient in project FirebaseUI-Android by firebase.
the class CheckEmailFragment method getEmailHintIntent.
private PendingIntent getEmailHintIntent() {
GoogleApiClient client = new GoogleApiClient.Builder(getContext()).addApi(Auth.CREDENTIALS_API).enableAutoManage(getActivity(), GoogleApiHelper.getSafeAutoManageId(), new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
Log.e(TAG, "Client connection failed: " + connectionResult.getErrorMessage());
}
}).build();
HintRequest hintRequest = new HintRequest.Builder().setHintPickerConfig(new CredentialPickerConfig.Builder().setShowCancelButton(true).build()).setEmailAddressIdentifierSupported(true).build();
return Auth.CredentialsApi.getHintPickerIntent(client, hintRequest);
}
use of com.google.android.gms.common.api.GoogleApiClient in project FirebaseUI-Android by firebase.
the class AuthUI method signOut.
/**
* Signs the current user out, if one is signed in.
*
* @param activity The activity requesting the user be signed out.
* @return a task which, upon completion, signals that the user has been signed out ({@code
* result.isSuccess()}, or that the sign-out attempt failed unexpectedly ({@code
* !result.isSuccess()}).
* @deprecated use {@link #signOut(FragmentActivity)} instead
*/
@Deprecated
public Task<Void> signOut(@NonNull Activity activity) {
// Get helper for Google Sign In and Credentials API
GoogleApiClientTaskHelper taskHelper = GoogleApiClientTaskHelper.getInstance(activity);
taskHelper.getBuilder().addApi(Auth.CREDENTIALS_API).addApi(Auth.GOOGLE_SIGN_IN_API, GoogleSignInOptions.DEFAULT_SIGN_IN);
// Get Credentials Helper
CredentialTaskApi credentialsHelper = CredentialsApiHelper.getInstance(taskHelper);
// Firebase Sign out
mAuth.signOut();
// Disable credentials auto sign-in
Task<Status> disableCredentialsTask = credentialsHelper.disableAutoSignIn();
// Google sign out
Task<Void> googleSignOutTask = taskHelper.getConnectedGoogleApiClient().continueWith(new Continuation<GoogleApiClient, Void>() {
@Override
public Void then(@NonNull Task<GoogleApiClient> task) throws Exception {
if (task.isSuccessful()) {
Auth.GoogleSignInApi.signOut(task.getResult());
}
return null;
}
});
// Facebook sign out
LoginManager.getInstance().logOut();
// Wait for all tasks to complete
return Tasks.whenAll(disableCredentialsTask, googleSignOutTask);
}
use of com.google.android.gms.common.api.GoogleApiClient in project Android-ReactiveLocation by mcharmas.
the class BaseObservable method createApiClient.
protected GoogleApiClient createApiClient(Subscriber<? super T> subscriber) {
ApiClientConnectionCallbacks apiClientConnectionCallbacks = new ApiClientConnectionCallbacks(subscriber);
GoogleApiClient.Builder apiClientBuilder = new GoogleApiClient.Builder(ctx);
for (Api<? extends Api.ApiOptions.NotRequiredOptions> service : services) {
apiClientBuilder.addApi(service);
}
apiClientBuilder.addConnectionCallbacks(apiClientConnectionCallbacks);
apiClientBuilder.addOnConnectionFailedListener(apiClientConnectionCallbacks);
GoogleApiClient apiClient = apiClientBuilder.build();
apiClientConnectionCallbacks.setClient(apiClient);
return apiClient;
}
Aggregations