@Override
        protected Intent getActivityIntent() {
          // Make sure the EULA screen is not shown.
          SettingsUtils.markTosAccepted(InstrumentationRegistry.getTargetContext(), true);

          // Create intent to load the keynote session.
          mSessionUri = ScheduleContract.Sessions.buildSessionUri(SESSION_ID);
          Intent intent = new Intent(Intent.ACTION_VIEW, mSessionUri);

          return intent;
        }
  @Override
  protected void onHandleIntent(Intent intent) {
    final String action = intent.getAction();
    Log.d(TAG, "Received intent: " + action);

    final ContentResolver resolver = getContentResolver();

    boolean isAddEvent = false;

    if (ACTION_ADD_SESSION_CALENDAR.equals(action)) {
      isAddEvent = true;

    } else if (ACTION_REMOVE_SESSION_CALENDAR.equals(action)) {
      isAddEvent = false;

    } else if (ACTION_UPDATE_ALL_SESSIONS_CALENDAR.equals(action)
        && SettingsUtils.shouldSyncCalendar(this)) {
      try {
        getContentResolver()
            .applyBatch(
                CalendarContract.AUTHORITY,
                processAllSessionsCalendar(resolver, getCalendarId(intent)));
        sendBroadcast(
            new Intent(SessionCalendarService.ACTION_UPDATE_ALL_SESSIONS_CALENDAR_COMPLETED));
      } catch (RemoteException e) {
        LOGE(TAG, "Error adding all sessions to Google Calendar", e);
      } catch (OperationApplicationException e) {
        LOGE(TAG, "Error adding all sessions to Google Calendar", e);
      }

    } else if (ACTION_CLEAR_ALL_SESSIONS_CALENDAR.equals(action)) {
      try {
        getContentResolver()
            .applyBatch(
                CalendarContract.AUTHORITY,
                processClearAllSessions(resolver, getCalendarId(intent)));
      } catch (RemoteException e) {
        LOGE(TAG, "Error clearing all sessions from Google Calendar", e);
      } catch (OperationApplicationException e) {
        LOGE(TAG, "Error clearing all sessions from Google Calendar", e);
      }

    } else {
      return;
    }

    final Uri uri = intent.getData();
    final Bundle extras = intent.getExtras();
    if (uri == null || extras == null || !SettingsUtils.shouldSyncCalendar(this)) {
      return;
    }

    try {
      resolver.applyBatch(
          CalendarContract.AUTHORITY,
          processSessionCalendar(
              resolver,
              getCalendarId(intent),
              isAddEvent,
              uri,
              extras.getLong(EXTRA_SESSION_START),
              extras.getLong(EXTRA_SESSION_END),
              extras.getString(EXTRA_SESSION_TITLE),
              extras.getString(EXTRA_SESSION_ROOM)));
    } catch (RemoteException e) {
      LOGE(TAG, "Error adding session to Google Calendar", e);
    } catch (OperationApplicationException e) {
      LOGE(TAG, "Error adding session to Google Calendar", e);
    }
  }