Search in sources :

Example 16 with Status

use of com.google.android.gms.common.api.Status 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 ({@link
     * Task#isSuccessful()}, or that the sign-out attempt failed unexpectedly !{@link
     * Task#isSuccessful()}).
     */
public Task<Void> signOut(@NonNull FragmentActivity activity) {
    // Get Credentials Helper
    GoogleSignInHelper credentialsHelper = GoogleSignInHelper.getInstance(activity);
    // Firebase Sign out
    mAuth.signOut();
    // Disable credentials auto sign-in
    Task<Status> disableCredentialsTask = credentialsHelper.disableAutoSignIn();
    // Google sign out
    Task<Status> signOutTask = credentialsHelper.signOut();
    // Facebook sign out
    LoginManager.getInstance().logOut();
    // Wait for all tasks to complete
    return Tasks.whenAll(disableCredentialsTask, signOutTask);
}
Also used : Status(com.google.android.gms.common.api.Status) GoogleSignInHelper(com.firebase.ui.auth.util.GoogleSignInHelper)

Example 17 with Status

use of com.google.android.gms.common.api.Status in project FirebaseUI-Android by firebase.

the class GoogleProvider method onError.

private void onError(GoogleSignInResult result) {
    Status status = result.getStatus();
    if (status.getStatusCode() == CommonStatusCodes.INVALID_ACCOUNT) {
        mGoogleApiClient.stopAutoManage(mActivity);
        mGoogleApiClient.disconnect();
        mGoogleApiClient = new GoogleApiClient.Builder(mActivity).enableAutoManage(mActivity, GoogleApiHelper.getSafeAutoManageId(), this).addApi(Auth.GOOGLE_SIGN_IN_API, getSignInOptions(null)).build();
        startLogin(mActivity);
    } else {
        onError(status.getStatusCode() + " " + status.getStatusMessage());
    }
}
Also used : Status(com.google.android.gms.common.api.Status)

Example 18 with Status

use of com.google.android.gms.common.api.Status in project FirebaseUI-Android by firebase.

the class SignInDelegate method onResult.

@Override
public void onResult(@NonNull CredentialRequestResult result) {
    Status status = result.getStatus();
    if (status.isSuccess()) {
        // Auto sign-in success
        handleCredential(result.getCredential());
        return;
    } else if (status.hasResolution()) {
        try {
            if (status.getStatusCode() == CommonStatusCodes.RESOLUTION_REQUIRED) {
                mHelper.startIntentSenderForResult(status.getResolution().getIntentSender(), RC_CREDENTIALS_READ);
                return;
            } else if (!getSupportedAccountTypes().isEmpty()) {
                mHelper.startIntentSenderForResult(status.getResolution().getIntentSender(), RC_CREDENTIALS_READ);
                return;
            }
        } catch (IntentSender.SendIntentException e) {
            Log.e(TAG, "Failed to send Credentials intent.", e);
        }
    }
    startAuthMethodChoice();
}
Also used : Status(com.google.android.gms.common.api.Status)

Example 19 with Status

use of com.google.android.gms.common.api.Status in project Android-ReactiveLocation by mcharmas.

the class GeofenceActivity method addGeofence.

private void addGeofence() {
    final GeofencingRequest geofencingRequest = createGeofencingRequest();
    if (geofencingRequest == null)
        return;
    final PendingIntent pendingIntent = createNotificationBroadcastPendingIntent();
    reactiveLocationProvider.removeGeofences(pendingIntent).flatMap(new Func1<Status, Observable<Status>>() {

        @Override
        public Observable<Status> call(Status pendingIntentRemoveGeofenceResult) {
            return reactiveLocationProvider.addGeofences(pendingIntent, geofencingRequest);
        }
    }).subscribe(new Action1<Status>() {

        @Override
        public void call(Status addGeofenceResult) {
            toast("Geofence added, success: " + addGeofenceResult.isSuccess());
        }
    }, new Action1<Throwable>() {

        @Override
        public void call(Throwable throwable) {
            toast("Error adding geofence.");
            Log.d(TAG, "Error adding geofence.", throwable);
        }
    });
}
Also used : Status(com.google.android.gms.common.api.Status) GeofencingRequest(com.google.android.gms.location.GeofencingRequest) PendingIntent(android.app.PendingIntent) Func1(rx.functions.Func1)

Example 20 with Status

use of com.google.android.gms.common.api.Status in project Android-ReactiveLocation by mcharmas.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    lastKnownLocationView = (TextView) findViewById(R.id.last_known_location_view);
    updatableLocationView = (TextView) findViewById(R.id.updated_location_view);
    addressLocationView = (TextView) findViewById(R.id.address_for_location_view);
    currentActivityView = (TextView) findViewById(R.id.activity_recent_view);
    locationProvider = new ReactiveLocationProvider(getApplicationContext());
    lastKnownLocationObservable = locationProvider.getLastKnownLocation();
    final LocationRequest locationRequest = LocationRequest.create().setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY).setNumUpdates(5).setInterval(100);
    locationUpdatesObservable = locationProvider.checkLocationSettings(new LocationSettingsRequest.Builder().addLocationRequest(locationRequest).setAlwaysShow(//Refrence: http://stackoverflow.com/questions/29824408/google-play-services-locationservices-api-new-option-never
    true).build()).doOnNext(new Action1<LocationSettingsResult>() {

        @Override
        public void call(LocationSettingsResult locationSettingsResult) {
            Status status = locationSettingsResult.getStatus();
            if (status.getStatusCode() == LocationSettingsStatusCodes.RESOLUTION_REQUIRED) {
                try {
                    status.startResolutionForResult(MainActivity.this, REQUEST_CHECK_SETTINGS);
                } catch (IntentSender.SendIntentException th) {
                    Log.e("MainActivity", "Error opening settings activity.", th);
                }
            }
        }
    }).flatMap(new Func1<LocationSettingsResult, Observable<Location>>() {

        @Override
        public Observable<Location> call(LocationSettingsResult locationSettingsResult) {
            return locationProvider.getUpdatedLocation(locationRequest);
        }
    });
    addressObservable = locationProvider.getUpdatedLocation(locationRequest).flatMap(new Func1<Location, Observable<List<Address>>>() {

        @Override
        public Observable<List<Address>> call(Location location) {
            return locationProvider.getReverseGeocodeObservable(location.getLatitude(), location.getLongitude(), 1);
        }
    }).map(new Func1<List<Address>, Address>() {

        @Override
        public Address call(List<Address> addresses) {
            return addresses != null && !addresses.isEmpty() ? addresses.get(0) : null;
        }
    }).map(new AddressToStringFunc()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
    activityObservable = locationProvider.getDetectedActivity(50);
}
Also used : Status(com.google.android.gms.common.api.Status) LocationRequest(com.google.android.gms.location.LocationRequest) LocationSettingsResult(com.google.android.gms.location.LocationSettingsResult) Address(android.location.Address) LocationSettingsRequest(com.google.android.gms.location.LocationSettingsRequest) List(java.util.List) ReactiveLocationProvider(pl.charmas.android.reactivelocation.ReactiveLocationProvider) Func1(rx.functions.Func1) AddressToStringFunc(pl.charmas.android.reactivelocation.sample.utils.AddressToStringFunc) Location(android.location.Location)

Aggregations

Status (com.google.android.gms.common.api.Status)35 LocationRequest (com.google.android.gms.location.LocationRequest)5 LocationSettingsResult (com.google.android.gms.location.LocationSettingsResult)5 Place (com.google.android.gms.location.places.Place)5 LatLng (com.google.android.gms.maps.model.LatLng)5 Activity (android.app.Activity)4 View (android.view.View)4 GoogleApiClient (com.google.android.gms.common.api.GoogleApiClient)4 PlaceSelectionListener (com.google.android.gms.location.places.ui.PlaceSelectionListener)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 LatLngBounds (com.google.android.gms.maps.model.LatLngBounds)3 IOException (java.io.IOException)3 DialogInterface (android.content.DialogInterface)2 Intent (android.content.Intent)2 IntentSender (android.content.IntentSender)2