在evernote中创建笔记时如何使用笔记附加PDF资源(android应用程序)

时间:2014-12-01 13:29:58

标签: android api evernote

在evernote中创建笔记时如何附加PDF资源和注释(android应用程序).​​how来创建资源列表。

1 个答案:

答案 0 :(得分:0)

以下是一些改编自Evernote Android SDK中的ImagePicker示例的示例代码,可以在samples / HelloEDAM / src / com / evernote / android / sample / ImagePicker.java第197到228行中找到

Here is a link到Evernote的Github帐户上的相关文件和行,他们将托管所有SDK。

// Hash the data in the PDF file. The hash is used to reference the
// file in the ENML note content.
InputStream in = new BufferedInputStream(new FileInputStream(f));
FileData data = new FileData(EvernoteUtil.hash(in), new File(f));
in.close();

// Create a new Resource
Resource resource = new Resource();
resource.setData(data);
resource.setMime(mPDFdata.mimeType);
ResourceAttributes attributes = new ResourceAttributes();
attributes.setFileName(mPDFdata.fileName);
resource.setAttributes(attributes);

// Create a new Note
Note note = new Note();
note.setTitle("Android test note");
note.addToResources(resource);

// Set the note's ENML content. Learn about ENML at
// http://dev.evernote.com/documentation/cloud/chapters/ENML.php
String content =
    EvernoteUtil.NOTE_PREFIX +
        "<p>This note was uploaded from Android. It contains an PDF.</p>" +
        EvernoteUtil.createEnMediaTag(resource) +
        EvernoteUtil.NOTE_SUFFIX;

note.setContent(content);

if(!mEvernoteSession.getAuthenticationResult().isAppLinkedNotebook()) {
  // Create the note on the server. The returned Note object
  // will contain server-generated attributes such as the note's
  // unique ID (GUID), the Resource's GUID, and the creation and update time.

  mEvernoteSession.getClientFactory().createNoteStoreClient().createNote(note, mCreateImageCallback);
} else {
  super.createNoteInAppLinkedNotebook(note, mCreateImageCallback);
}