메모 만들기

Google Keep API를 사용하면 텍스트 메모와 목록 메모의 두 가지 유형의 메모를 만들 수 있습니다. 이 문서에서는 각 유형을 만드는 방법을 보여줍니다.

텍스트 메모 만들기

다음 샘플은 텍스트 메모를 만드는 방법을 보여줍니다.

REST

메모 리소스와 함께 notes.create를 호출합니다. 메모의 SectionTextContent를 배치합니다.

Java

/**
 * Creates a new text note.
 *
 * @throws IOException
 * @return The newly created text note.
 */
private Note createTextNote(String title, String textContent) throws IOException {
  Section noteBody = new Section().setText(new TextContent().setText(textContent));
  Note newNote = new Note().setTitle(title).setBody(noteBody);

  return keepService.notes().create(newNote).execute();
}

목록 메모 만들기

다음 샘플은 목록 메모를 만드는 방법을 보여줍니다.

REST

메모 리소스와 함께 notes.create를 호출합니다. 메모의 SectionListContent를 배치합니다.

Java

/**
 * Creates a new list note.
 *
 * @throws IOException
 * @return The newly created list note.
 */
private Note createListNote() throws IOException {
  // Create a checked list item.
  ListItem checkedListItem =
      new ListItem().setText(new TextContent().setText("Send meeting invites")).setChecked(true);

  // Create a list item with two children.
  ListItem uncheckedListItemWithChildren =
      new ListItem()
          .setText(new TextContent().setText("Prepare the presentation"))
          .setChecked(false)
          .setChildListItems(
              Arrays.asList(
                  new ListItem().setText(new TextContent().setText("Review metrics")),
                  new ListItem().setText(new TextContent().setText("Analyze sales projections")),
                  new ListItem().setText(new TextContent().setText("Share with leads"))));

  // Creates an unchecked list item.
  ListItem uncheckedListItem =
      new ListItem().setText(new TextContent().setText("Send summary email")).setChecked(true);

  Note newNote =
      new Note()
          .setTitle("Marketing review meeting")
          .setBody(
              new Section()
                  .setList(
                      new ListContent()
                          .setListItems(
                              Arrays.asList(
                                  checkedListItem,
                                  uncheckedListItemWithChildren,
                                  uncheckedListItem))));

  return keepService.notes().create(newNote).execute();
}