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);
}
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());
}
}
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();
}
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);
}
});
}
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);
}
Aggregations