नोट बनाएं

Google Keep API से आप दो तरह के नोट बना सकते हैं: टेक्स्ट नोट और सूची नोट. इस दस्तावेज़ में हर टाइप को बनाने का तरीका बताया गया है.

लेख नोट बनाएं

नीचे दिए गए सैंपल में टेक्स्ट नोट बनाने का तरीका बताया गया है:

आराम

Note संसाधन की मदद से notes.create को कॉल करें. नोट के सेक्शन में TextContent डालें.

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

सूची नोट बनाना

नीचे दिए गए सैंपल में लिस्ट नोट बनाने का तरीका बताया गया है:

आराम

Note संसाधन की मदद से notes.create को कॉल करें. नोट के सेक्शन में ListContent डालें.

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