private static void requestAuth(Context context, UserRecoverableAuthIOException userRecoverableException) { LocalBroadcastManager manager = LocalBroadcastManager.getInstance(context); Intent authIntent = userRecoverableException.getIntent(); Intent runReqAuthIntent = new Intent(MainActivity.REQUEST_AUTHORIZATION_INTENT); runReqAuthIntent.putExtra(MainActivity.REQUEST_AUTHORIZATION_INTENT_PARAM, authIntent); manager.sendBroadcast(runReqAuthIntent); Log.d(TAG, String.format("Sent broadcast %s", MainActivity.REQUEST_AUTHORIZATION_INTENT)); }
@Override protected Void doInBackground(Void... voids) { YouTube youtube = new YouTube.Builder(transport, jsonFactory, credential).setApplicationName(Constants.APP_NAME) .build(); try { youtube.videos().update("snippet", updateVideo).execute(); } catch (UserRecoverableAuthIOException e) { startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION); } catch (IOException e) { Log.e(TAG, e.getMessage()); } return null; }
} catch (UserRecoverableAuthIOException userRecoverableException) { startActivityForResult( userRecoverableException.getIntent(), REQUEST_AUTHORIZATION); } catch (IOException e) {