یادداشت ایجاد کنید

رابط برنامه‌نویسی کاربردی گوگل کیپ (Google Keep API) به شما امکان می‌دهد دو نوع یادداشت ایجاد کنید: یادداشت متنی و یادداشت فهرستی. این سند نحوه ایجاد هر نوع را نشان می‌دهد.

ایجاد یادداشت متنی

نمونه زیر نحوه ایجاد یک یادداشت متنی را نشان می‌دهد:

استراحت

با استفاده از یک منبع Note، تابع notes.create را فراخوانی کنید. محتوای متن (TextContent) را در بخش (Section) یادداشت قرار دهید.

جاوا

/**
 * 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();
}

ایجاد یادداشت فهرست

نمونه زیر نحوه ایجاد یادداشت فهرست را نشان می‌دهد:

استراحت

با استفاده از یک منبع Note، تابع notes.create را فراخوانی کنید. محتوای ListContent را در بخش (Section) یادداشت قرار دهید.

جاوا

/**
 * 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();
}