2011-05-01 5 views
2

GData API for Google Calendar in Java을 사용하여 Google 캘린더에 연결하는 Android APP를 개발 중입니다. 지금까지 이벤트를 만들었지 만 제목, 설명 및 시간 만 설정할 수있었습니다.Google 캘린더 API : 새 이벤트 속성

누구나 이벤트에 설정할 수있는 모든 매개 변수가있는 참조 또는 샘플을 어디에서 찾을 수 있습니까?

나는 지금까지 내가 성취 한 것에 대한 몇 가지 코드를 남겨 두었다.

CalendarService calendarService = new CalendarService("CalendarAPP"); 
calendarService.setUserCredentials(<username>, <password>); 
URL postUrl = new URL("https://www.google.com/calendar/feeds/<GMAIL ACCOUNT>/private/full"); 
CalendarEventEntry myEntry = new CalendarEventEntry(); 

myEntry.setTitle(new PlainTextConstruct("Tennis with Beth")); 
myEntry.setContent(new PlainTextConstruct("Meet for a quick lesson.")); 

DateTime startTime = DateTime.now(); 
DateTime endTime = DateTime.now(); 
When eventTimes = new When(); 
eventTimes.setStartTime(startTime); 
eventTimes.setEndTime(endTime); 
myEntry.addTime(eventTimes); 

CalendarEventEntry insertedEntry = connection.getCalendarService().insert(postUrl, myEntry); 

미리 감사드립니다.

미키 완.

답변

1

Google 캘린더 용 GData 꽤 괜찮습니다. 설정하거나 가져올 수있는 모든 속성에는 Getter와 Setter가 정의되어 있습니다. 액세스하려는 데이터에 적합한 이벤트 항목에서 setter/getter를 찾아야합니다.

콘솔에 표시 할 수있는 거의 모든 데이터를 표시하는 방법의 예를 남깁니다.

즐기십시오!

private static void showCalendarEventEntry(CalendarEventEntry entry) { 
    assert entry != null; 
    System.out.println("-------------------------------------------"); 
    System.out.println("START showCalendarEventEntry"); 
    System.out.println(""); 
    System.out.println("ID: " + entry.getId()); 
    System.out.println("TITLE: "+entry.getTitle().getPlainText()); 
    System.out.println("DESCRIPTION: "+entry.getPlainTextContent()); 
    System.out.println("LOCATION: "+entry.getLocations().get(0).getValueString()); 

    System.out.println(""); 
    System.out.println("TIMES"); 
    if (entry.getTimes().size() > 0) { 
     When eventTimes = entry.getTimes().get(0); 
     if (eventTimes.getStartTime().isDateOnly()) { 
      System.out.println("\tWHEN: ALL DAY"); 
     } else { 
      System.out.println("\tWHEN: TIME"); 
     } 

     if (entry.getRecurrence() != null) 
      System.out.println("\tRECURRENCE: "+entry.getRecurrence().toString()); 

     System.out.println("\tSTART TIME: "+eventTimes.getStartTime()); 
     System.out.println("\tEND TIME: "+eventTimes.getEndTime()); 
    } 

    System.out.println(""); 
    System.out.println("PARTICIPANTS"); 
    System.out.println("\t"+(entry.getParticipants().size()) + " PARTICIPANTS"); 
    if (entry.getParticipants().size() > 0){ 

     for (int i=0; i<entry.getParticipants().size(); i++) { 
      EventWho participant = entry.getParticipants().get(i); 
      System.out.println("\t\tPARTICIPANT "+participant.getValueString()); 
      System.out.println("\t\t\tTYPE: "+participant.getAttendeeType()); 
      System.out.println("\t\t\tSTATUS: "+participant.getAttendeeStatus()); 
     } 
     if (entry.isGuestsCanInviteOthers()) 
      System.out.println("\tGUESTS CAN INVITE OTHERS: "); 
     if (entry.isGuestsCanModify()) 
      System.out.println("\tGUESTS CAN MODIFY"); 
     if (entry.isGuestsCanSeeGuests()) 
      System.out.println("\tGUESTS CAN SEE GUESTS"); 
    } 

    //REMINDERS 
    System.out.println(""); 
    System.out.println("REMINDERS"); 
    System.out.println("\t"+entry.getReminder().size()+" REMINDERS"); 
    if (entry.getReminder().size() > 0) { 
     for (int i=0; i<entry.getReminder().size(); i++) { 
      Reminder reminder = entry.getReminder().get(i); 
      System.out.println("\t\tREMINDER "+i); 
      System.out.println("\t\t\tMETHOD: "+reminder.getMethod().toString()); 
      System.out.println("\t\t\tDAYS: "+reminder.getDays()); 
      System.out.println("\t\t\tHOURS: "+reminder.getHours()); 
      System.out.println("\t\t\tMINUTES: "+reminder.getMinutes());     
     } 
    } 

    //VISIBILITY 
    System.out.println(""); 
    System.out.println("VISIBILITY: "+entry.getVisibility().getValue()); 

    System.out.println(""); 
    System.out.println("END showCalendarEventEntry"); 
    System.out.println("-------------------------------------------"); 
} 
관련 문제