com.google.api.client.googleapis.extensions.android.gms.auth.UserRecoverableAuthIOException Java Examples
The following examples show how to use
com.google.api.client.googleapis.extensions.android.gms.auth.UserRecoverableAuthIOException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseGmailProvider.java From PrivacyStreams with Apache License 2.0 | 6 votes |
/** * Background task to call Gmail API. * @param queries the gmail api query. */ @Override protected List<String> doInBackground(String... queries) { try { return getDataFromApi(queries[0]); } catch (Exception e) { if (e instanceof UserRecoverableAuthIOException) { Intent authorizationIntent = new Intent(getContext(), GmailAuthorizationActivity.class) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); authorizationIntent.setAction("UserRecoverableAuthIOException"); authorizationIntent.putExtra("request_authorization", ((UserRecoverableAuthIOException) e).getIntent()); getContext().startActivity(authorizationIntent); } else { Logging.error("The following error occurred:\n" + e.getMessage()); } return null; } }
Example #2
Source File: CheckupReminders.java From Crimson with Apache License 2.0 | 6 votes |
@Override protected void onCancelled() { mProgress.hide(); if (mLastError != null) { if (mLastError instanceof GooglePlayServicesAvailabilityIOException) { showGooglePlayServicesAvailabilityErrorDialog( ((GooglePlayServicesAvailabilityIOException) mLastError) .getConnectionStatusCode()); } else if (mLastError instanceof UserRecoverableAuthIOException) { startActivityForResult( ((UserRecoverableAuthIOException) mLastError).getIntent(), CheckupReminders.REQUEST_AUTHORIZATION); } else { //mOutputText.setText("The following error occurred:\n"+ mLastError.getMessage()); } } else { // mOutputText.setText("Request cancelled."); } }
Example #3
Source File: MainActivity.java From apps-script-mobile-addons with Apache License 2.0 | 6 votes |
/** * Handle cancel requests -- specifically, those caused by exceptions * raised when attempting to call the API. */ @Override protected void onCancelled() { mProgress.hide(); if (mLastError != null) { if (mLastError instanceof GooglePlayServicesAvailabilityIOException) { showGooglePlayServicesAvailabilityErrorDialog( ((GooglePlayServicesAvailabilityIOException) mLastError).getConnectionStatusCode()); } else if (mLastError instanceof UserRecoverableAuthIOException) { startActivityForResult( ((UserRecoverableAuthIOException) mLastError).getIntent(), MainActivity.REQUEST_AUTHORIZATION); } else { showErrorDialog(mLastError.toString()); } } }
Example #4
Source File: ApiAsyncTask.java From CalendarQuickStart with MIT License | 6 votes |
/** * Background task to call Google Calendar API. * @param params no parameters needed for this task. */ @Override protected Void doInBackground(Void... params) { try { mActivity.clearResultsText(); mActivity.updateResultsText(getDataFromApi()); } catch (final GooglePlayServicesAvailabilityIOException availabilityException) { mActivity.showGooglePlayServicesAvailabilityErrorDialog( availabilityException.getConnectionStatusCode()); } catch (UserRecoverableAuthIOException userRecoverableException) { mActivity.startActivityForResult( userRecoverableException.getIntent(), MainActivity.REQUEST_AUTHORIZATION); } catch (IOException e) { mActivity.updateStatus("The following error occurred: " + e.getMessage()); } return null; }
Example #5
Source File: CommonAsyncTask.java From SimplePomodoro-android with MIT License | 6 votes |
@Override protected final Boolean doInBackground(Void... ignored) { try { doInBackground(); return true; } catch (final GooglePlayServicesAvailabilityIOException availabilityException) { mFragment.showGooglePlayServicesAvailabilityErrorDialog( availabilityException.getConnectionStatusCode()); } catch (UserRecoverableAuthIOException userRecoverableException) { mFragment.startActivityForResult( userRecoverableException.getIntent(), TaskListFragment.REQUEST_AUTHORIZATION); } catch (IOException e) { Utils.logAndShow(mFragment.getActivity(), TaskListFragment.TAG, e); } return false; }
Example #6
Source File: FragmentAsyncTask.java From SimplePomodoro-android with MIT License | 6 votes |
@Override protected final Boolean doInBackground(Void... ignored) { try { doInBackground(); return true; } catch (final GooglePlayServicesAvailabilityIOException availabilityException) { mFragment.showGooglePlayServicesAvailabilityErrorDialog( availabilityException.getConnectionStatusCode()); } catch (UserRecoverableAuthIOException userRecoverableException) { mFragment.startActivityForResult( userRecoverableException.getIntent(), TaskListFragment.REQUEST_AUTHORIZATION); } catch (IOException e) { Utils.logAndShow(mFragment.getActivity(), TaskListFragment.TAG, e); } return false; }
Example #7
Source File: RestApiActivity.java From google-services with Apache License 2.0 | 5 votes |
@Override protected List<Person> doInBackground(Account... accounts) { if (mActivityRef.get() == null) { return null; } Context context = mActivityRef.get().getApplicationContext(); try { GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2( context, Collections.singleton(CONTACTS_SCOPE)); credential.setSelectedAccount(accounts[0]); PeopleService service = new PeopleService.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential) .setApplicationName("Google Sign In Quickstart") .build(); ListConnectionsResponse connectionsResponse = service .people() .connections() .list("people/me") .setFields("names,emailAddresses") .execute(); return connectionsResponse.getConnections(); } catch (UserRecoverableAuthIOException recoverableException) { if (mActivityRef.get() != null) { mActivityRef.get().onRecoverableAuthException(recoverableException); } } catch (IOException e) { Log.w(TAG, "getContacts:exception", e); } return null; }
Example #8
Source File: DriveSyncAndroidService.java From science-journal with Apache License 2.0 | 4 votes |
/** * Handle action sync experiment library in the provided background thread with the provided * parameters. */ private void handleActionSyncLibrary( DriveSyncManager driveApi, String accountKey, ExperimentLibraryManager elm, LocalSyncManager lsm) { String progressKey = accountKey + EXPERIMENT_PROTO; try { driveApi.syncExperimentLibraryInBackgroundThread(getApplicationContext(), elm, lsm); updateProgress(DriveSyncProgress.getComplete(progressKey)); } catch (UserRecoverableAuthIOException e) { updateProgress(DriveSyncProgress.fromThrowable(progressKey, e)); Intent intent = e.getIntent(); // Need to start a new task, since we're calling this from a service intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } catch (UnknownHostException uhe) { updateProgress(DriveSyncProgress.fromThrowable(progressKey, uhe)); AppSingleton.getInstance(getApplicationContext()).setSyncServiceBusy(false); if (Log.isLoggable(TAG, Log.ERROR)) { Log.e(TAG, "UnknownHost Exception", uhe); } } catch (IOException ioe) { Log.e(TAG, ioe.getClass().toString()); updateProgress(DriveSyncProgress.fromThrowable(progressKey, ioe)); AppSingleton.getInstance(getApplicationContext()).setSyncServiceBusy(false); if (Log.isLoggable(TAG, Log.ERROR)) { Log.e(TAG, "IO Exception", ioe); } String labelFromStackTrace = TrackerConstants.createLabelFromStackTrace(ioe); UsageTracker usageTracker = WhistlePunkApplication.getUsageTracker(getApplicationContext()); usageTracker.trackEvent( TrackerConstants.CATEGORY_SYNC, TrackerConstants.ACTION_SYNC_FAILED, labelFromStackTrace, 0); if (Throwables.getStackTraceAsString(ioe).contains(REASON_USER_RATE_LIMIT_EXCEEDED)) { usageTracker.trackEvent( TrackerConstants.CATEGORY_FAILURE, TrackerConstants.ACTION_SYNC_FAILED_USER_RATE_LIMIT_EXCEEDED, labelFromStackTrace, 0); } else { usageTracker.trackEvent( TrackerConstants.CATEGORY_FAILURE, TrackerConstants.ACTION_SYNC_FAILED, labelFromStackTrace, 0); } showToast(R.string.sync_failed); } }
Example #9
Source File: RestApiActivity.java From google-services with Apache License 2.0 | 4 votes |
protected void onRecoverableAuthException(UserRecoverableAuthIOException recoverableException) { Log.w(TAG, "onRecoverableAuthException", recoverableException); startActivityForResult(recoverableException.getIntent(), RC_RECOVERABLE); }