// 2016-03-29 시청예약시 데이타베이스 처리를 programId 로 하는데 서버에서 programId를 중복으로 보내고 있다
  // 그래서 시청시간을 추가함.
  public void removeWatchTvReserveAlarmWithProgramIdAndStartTime(
      String programId, String startTime) {
    int iSeq = 0;
    Realm realm = Realm.getInstance(mContext);
    realm.beginTransaction();
    RealmResults<WatchTvObject> results =
        mRealm
            .where(WatchTvObject.class)
            .equalTo("sProgramId", programId)
            .equalTo("sProgramBroadcastingStartTime", startTime)
            .findAll();
    if (results.size() > 0) {
      WatchTvObject obj = results.get(0);
      iSeq = obj.getiSeq();
      obj.removeFromRealm();
    } else {
      //
    }
    realm.commitTransaction();

    AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
    Intent intent = new Intent(mContext, WatchTvAlarmBroadcastReceiver.class);
    PendingIntent pendingIntent =
        PendingIntent.getBroadcast(mContext, iSeq, intent, PendingIntent.FLAG_NO_CREATE);
    if (pendingIntent != null) {
      alarmManager.cancel(pendingIntent);
      pendingIntent.cancel();
    }
  }
  /**
   * @param programId "S321387639"
   * @param seriesId ""
   * @param programTitle "국악무대"
   * @param programBroadcastingStartTime 2015-11-10 16:02:00"
   *     <p>mPref.addWatchTvAlarm("S321387639", "", "국악무대1", "2015-11-10 18:50:00");
   *     mPref.addWatchTvAlarm("S321387640", "", "국악무대2", "2015-11-10 18:51:00");
   *     mPref.addWatchTvAlarm("S321387641", "", "국악무대3", "2015-11-10 18:52:00");
   *     mPref.addWatchTvAlarm("S321387642", "", "국악무대4", "2015-11-10 18:53:00");
   *     mPref.addWatchTvAlarm("S321387643", "", "국악무대5", "2015-11-10 18:54:00");
   */
  public void addWatchTvReserveAlarm(
      String programId, String seriesId, String programTitle, String programBroadcastingStartTime) {

    // Realm Database **********************************************************************
    // Obtain a Realm instance
    Realm realm = Realm.getInstance(mContext);

    // remove all
    realm.beginTransaction();
    WatchTvObject obj = realm.createObject(WatchTvObject.class); // Create a new object
    long iSeq = realm.where(WatchTvObject.class).maximumInt("iSeq") + 1;
    obj.setiSeq((int) iSeq);
    obj.setsScheduleSeq("");
    obj.setsBroadcastingDate("");
    obj.setsProgramId(programId);
    obj.setsSeriesId(seriesId);
    obj.setsProgramTitle(programTitle);
    obj.setsProgramContent("");
    obj.setsProgramBroadcastingStartTime(programBroadcastingStartTime);
    obj.setsProgramBroadcastingEndTime("");
    obj.setsProgramHD("");
    obj.setsProgramGrade("");
    obj.setsProgramPVR("");
    // 트랜잭션 종료
    realm.commitTransaction();
    // Realm Database **********************************************************************

    Date startDate = null;
    Calendar calendar = Calendar.getInstance();
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    try {
      startDate = formatter.parse(programBroadcastingStartTime);
    } catch (ParseException e) {
      e.printStackTrace();
    }
    calendar.setTime(startDate);

    Intent intent = new Intent(mContext, WatchTvAlarmBroadcastReceiver.class);
    intent.putExtra("programId", programId);
    intent.putExtra("seriesId", seriesId);
    intent.putExtra("programTitle", programTitle);
    intent.putExtra("programBroadcastingStartTime", programBroadcastingStartTime);
    intent.putExtra("iSeq", String.valueOf(iSeq));

    //        PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, (int)iSeq, intent,
    // PendingIntent.FLAG_NO_CREATE);
    PendingIntent pendingIntent =
        PendingIntent.getBroadcast(mContext, (int) iSeq, intent, PendingIntent.FLAG_ONE_SHOT);
    //        PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, (int)iSeq, intent,
    // PendingIntent.FLAG_UPDATE_CURRENT );

    AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
    //        alarmManager.set(AlarmManager.RTC, calendar.getTimeInMillis(), pendingIntent);
    alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
  }