use of com.google.android.gms.common.api.ApiException in project google-services by googlesamples.
the class IdTokenActivity method handleSignInResult.
// [START handle_sign_in_result]
private void handleSignInResult(@NonNull Task<GoogleSignInAccount> completedTask) {
try {
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
String idToken = account.getIdToken();
// TODO(developer): send ID Token to server and validate
updateUI(account);
} catch (ApiException e) {
Log.w(TAG, "handleSignInResult:error", e);
updateUI(null);
}
}
use of com.google.android.gms.common.api.ApiException in project google-services by googlesamples.
the class SignInActivity method handleSignInResult.
// [END onActivityResult]
// [START handleSignInResult]
private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
try {
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
// Signed in successfully, show authenticated UI.
updateUI(account);
} catch (ApiException e) {
// The ApiException status code indicates the detailed failure reason.
// Please refer to the GoogleSignInStatusCodes class reference for more information.
Log.w(TAG, "signInResult:failed code=" + e.getStatusCode());
updateUI(null);
}
}
use of com.google.android.gms.common.api.ApiException in project google-services by googlesamples.
the class SignInActivityWithDrive method handleSignInResult.
// [END onActivityResult]
// [START handleSignInResult]
private void handleSignInResult(@Nullable Task<GoogleSignInAccount> completedTask) {
Log.d(TAG, "handleSignInResult:" + completedTask.isSuccessful());
try {
// Signed in successfully, show authenticated U
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
updateUI(account);
} catch (ApiException e) {
// Signed out, show unauthenticated UI.
Log.w(TAG, "handleSignInResult:error", e);
updateUI(null);
}
}
use of com.google.android.gms.common.api.ApiException in project Precisely by Pankaj-Baranwal.
the class SignUp method handleSignInResult.
private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
try {
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
Constants.user_name = account.getDisplayName();
submitData(account.getId());
} catch (ApiException e) {
Toast.makeText(this, "Google behaving weirdly!", Toast.LENGTH_SHORT).show();
}
}
use of com.google.android.gms.common.api.ApiException in project wiseasily by eFishery.
the class MainActivity method initLocationParameters.
private void initLocationParameters() {
LocationRequest mLocationRequest = new LocationRequest();
mLocationRequest.setPriority(LocationRequest.PRIORITY_LOW_POWER);
LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();
builder.addLocationRequest(mLocationRequest);
LocationSettingsRequest locationSettingsRequest = builder.build();
Task<LocationSettingsResponse> result = LocationServices.getSettingsClient(this).checkLocationSettings(locationSettingsRequest);
result.addOnCompleteListener(new OnCompleteListener<LocationSettingsResponse>() {
@Override
public void onComplete(@NonNull Task<LocationSettingsResponse> task) {
try {
LocationSettingsResponse response = task.getResult(ApiException.class);
tryToConnect();
} catch (ApiException exception) {
switch(exception.getStatusCode()) {
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
try {
ResolvableApiException resolvable = (ResolvableApiException) exception;
resolvable.startResolutionForResult(MainActivity.this, REQUEST_CHECK_SETTINGS);
} catch (IntentSender.SendIntentException e) {
Log.d("MainActivity_Location", e.toString());
} catch (ClassCastException e) {
Log.d("MainActivity_Location", e.toString());
}
break;
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
Log.d("MainActivity_Location", "LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE");
break;
}
}
}
});
}
Aggregations