Search in sources :

Example 1 with Status

use of com.google.android.gms.common.api.Status in project AndroidChromium by JackyAndroid.

the class CreateRouteRequest method onResult.

@Override
public void onResult(Cast.ApplicationConnectionResult result) {
    if (mState != STATE_LAUNCHING_APPLICATION && mState != STATE_API_CONNECTION_SUSPENDED) {
        throwInvalidState();
    }
    Status status = result.getStatus();
    if (!status.isSuccess()) {
        Log.e(TAG, "Launch application failed with status: %s, %d, %s", mSource.getApplicationId(), status.getStatusCode(), status.getStatusMessage());
        reportError();
    }
    mState = STATE_LAUNCH_SUCCEEDED;
    reportSuccess(result);
}
Also used : Status(com.google.android.gms.common.api.Status)

Example 2 with Status

use of com.google.android.gms.common.api.Status in project WordPress-Android by wordpress-mobile.

the class SmartLockHelper method saveCredentialsInSmartLock.

public void saveCredentialsInSmartLock(@NonNull final String username, @NonNull final String password, @NonNull final String displayName, @NonNull final Uri profilePicture) {
    Activity activity = getActivityAndCheckAvailability();
    if (activity == null || mCredentialsClient == null || !mCredentialsClient.isConnected()) {
        return;
    }
    Credential credential = new Credential.Builder(username).setPassword(password).setName(displayName).setProfilePictureUri(profilePicture).build();
    Auth.CredentialsApi.save(mCredentialsClient, credential).setResultCallback(new ResultCallback<Status>() {

        @Override
        public void onResult(@NonNull Status status) {
            if (!status.isSuccess() && status.hasResolution()) {
                try {
                    Activity activity = getActivityAndCheckAvailability();
                    if (activity == null) {
                        return;
                    }
                    // This prompt the user to resolve the save request
                    status.startResolutionForResult(activity, SignInActivity.SMART_LOCK_SAVE);
                } catch (IntentSender.SendIntentException e) {
                // Could not resolve the request
                }
            }
        }
    });
}
Also used : Status(com.google.android.gms.common.api.Status) Credential(com.google.android.gms.auth.api.credentials.Credential) FragmentActivity(android.support.v4.app.FragmentActivity) Activity(android.app.Activity)

Example 3 with Status

use of com.google.android.gms.common.api.Status in project WordPress-Android by wordpress-mobile.

the class SmartLockHelper method deleteCredentialsInSmartLock.

public void deleteCredentialsInSmartLock(@NonNull final String username, @NonNull final String password) {
    Activity activity = getActivityAndCheckAvailability();
    if (activity == null || mCredentialsClient == null || !mCredentialsClient.isConnected()) {
        return;
    }
    Credential credential = new Credential.Builder(username).setPassword(password).build();
    Auth.CredentialsApi.delete(mCredentialsClient, credential).setResultCallback(new ResultCallback<Status>() {

        @Override
        public void onResult(@NonNull Status status) {
            AppLog.i(T.NUX, status.isSuccess() ? "SmartLock: credentials deleted for username: " + username : "SmartLock: Credentials not deleted for username: " + username);
        }
    });
}
Also used : Status(com.google.android.gms.common.api.Status) Credential(com.google.android.gms.auth.api.credentials.Credential) FragmentActivity(android.support.v4.app.FragmentActivity) Activity(android.app.Activity)

Example 4 with Status

use of com.google.android.gms.common.api.Status in project WordPress-Android by wordpress-mobile.

the class SmartLockHelper method smartLockAutoFill.

public void smartLockAutoFill(@NonNull final Callback callback) {
    Activity activity = getActivityAndCheckAvailability();
    if (activity == null || mCredentialsClient == null || !mCredentialsClient.isConnected()) {
        return;
    }
    CredentialRequest credentialRequest = new CredentialRequest.Builder().setPasswordLoginSupported(true).build();
    Auth.CredentialsApi.request(mCredentialsClient, credentialRequest).setResultCallback(new ResultCallback<CredentialRequestResult>() {

        @Override
        public void onResult(@NonNull CredentialRequestResult result) {
            Status status = result.getStatus();
            if (status.isSuccess()) {
                Credential credential = result.getCredential();
                callback.onCredentialRetrieved(credential);
            } else {
                if (status.getStatusCode() == CommonStatusCodes.RESOLUTION_REQUIRED) {
                    try {
                        Activity activity = getActivityAndCheckAvailability();
                        if (activity == null) {
                            return;
                        }
                        // Prompt the user to choose a saved credential
                        status.startResolutionForResult(activity, SignInActivity.SMART_LOCK_READ);
                    } catch (IntentSender.SendIntentException e) {
                        AppLog.d(T.NUX, "SmartLock: Failed to send resolution for credential request");
                    }
                } else {
                    // The user must create an account or log in manually.
                    AppLog.d(T.NUX, "SmartLock: Unsuccessful credential request.");
                }
            }
        }
    });
}
Also used : Status(com.google.android.gms.common.api.Status) CredentialRequest(com.google.android.gms.auth.api.credentials.CredentialRequest) Credential(com.google.android.gms.auth.api.credentials.Credential) FragmentActivity(android.support.v4.app.FragmentActivity) Activity(android.app.Activity) CredentialRequestResult(com.google.android.gms.auth.api.credentials.CredentialRequestResult)

Example 5 with Status

use of com.google.android.gms.common.api.Status in project mobile-messaging-sdk-android by infobip.

the class GeofencingImpl method startGeoMonitoring.

@SuppressWarnings("MissingPermission")
@Override
public void startGeoMonitoring() {
    if (!PlayServicesSupport.isPlayServicesAvailable(context) || !GeofencingHelper.isGeoActivated(context) || // checking this to avoid multiple activation of geofencing API on Play services
    GeofencingHelper.areAllActiveGeoAreasMonitored(context)) {
        return;
    }
    if (!checkRequiredPermissions()) {
        return;
    }
    Pair<List<Geofence>, Pair<Date, Date>> tuple = calculateGeofencesToMonitorAndNextCheckDates(messageStore);
    Date nextRefreshDate = tuple.second.first;
    Date nextExpireDate = tuple.second.second;
    scheduleRefresh(context, nextRefreshDate);
    scheduleExpiry(context, nextExpireDate);
    geofences = tuple.first;
    if (geofences.isEmpty()) {
        return;
    }
    requestType = GoogleApiClientRequestType.ADD_GEOFENCES;
    if (!googleApiClient.isConnected()) {
        googleApiClient.connect();
        return;
    }
    LocationServices.GeofencingApi.addGeofences(googleApiClient, geofencingRequest(), geofencePendingIntent()).setResultCallback(new ResultCallback<Status>() {

        @Override
        public void onResult(@NonNull Status status) {
            logGeofenceStatus(status, true);
            requestType = GoogleApiClientRequestType.NONE;
            GeofencingHelper.setAllActiveGeoAreasMonitored(context, status.isSuccess());
        }
    });
}
Also used : Status(com.google.android.gms.common.api.Status) ArrayList(java.util.ArrayList) List(java.util.List) Date(java.util.Date) Pair(android.util.Pair)

Aggregations

Status (com.google.android.gms.common.api.Status)32 LocationRequest (com.google.android.gms.location.LocationRequest)5 LocationSettingsResult (com.google.android.gms.location.LocationSettingsResult)5 Activity (android.app.Activity)4 GoogleApiClient (com.google.android.gms.common.api.GoogleApiClient)4 PendingIntent (android.app.PendingIntent)3 Location (android.location.Location)3 FragmentActivity (android.support.v4.app.FragmentActivity)3 WritableMap (com.facebook.react.bridge.WritableMap)3 Credential (com.google.android.gms.auth.api.credentials.Credential)3 LocationSettingsRequest (com.google.android.gms.location.LocationSettingsRequest)3 LatLng (com.google.android.gms.maps.model.LatLng)3 IOException (java.io.IOException)3 Intent (android.content.Intent)2 IntentSender (android.content.IntentSender)2 Address (android.location.Address)2 LocationManager (android.location.LocationManager)2 Bundle (android.os.Bundle)2 View (android.view.View)2 ServiceCommandError (com.connectsdk.service.command.ServiceCommandError)2