0
我正在做一個使用Android的Evernote的SDK的項目。我試圖從我的筆記(onItemClick)中獲取內容,但每次使用該方法時,應用程序都會崩潰,並顯示一個線程異常。 這是代碼的部分,我使用的方法:Evernote getNoteContent()Asynctask錯誤
public void onFragmentInteraction(Note note) throws EDAMUserException, EDAMSystemException, EDAMNotFoundException, TException, ExecutionException, InterruptedException {
String noteGuid = note.getGuid();
String Content = new GetNoteTask().execute(noteGuid).get();
Intent intent = new Intent(this, ViewNoteActivity.class);
intent.putExtra(intent.EXTRA_TEXT, Content);
startActivity(intent);
}
public class GetNoteTask extends AsyncTask<String, Void, String> {
private EvernoteSession mEvernoteSession;
public String noteContent(String guid) throws EDAMUserException, EDAMSystemException, TException, EDAMNotFoundException {
final EvernoteNoteStoreClient noteStoreClient = mEvernoteSession.getEvernoteClientFactory().getNoteStoreClient();
String noteText;
noteText = noteStoreClient.getNoteContent(guid);
return noteText;
}
@Override
protected String doInBackground(String... params) {
String guid = params[0];
String noteContent = null;
try {
noteContent = noteContent(guid);
} catch (EDAMUserException e) {
e.printStackTrace();
} catch (EDAMSystemException e) {
e.printStackTrace();
} catch (TException e) {
e.printStackTrace();
} catch (EDAMNotFoundException e) {
e.printStackTrace();
}
return noteContent;
}
}
第一種方法是在位於我的MainActivity延伸的片段。第二個是我的任務來獲取內容說明。當我向asynctask中的Evernote客戶開放時,它會中斷。
final EvernoteNoteStoreClient noteStoreClient = mEvernoteSession.getEvernoteClientFactory().getNoteStoreClient();
String noteText;
謝謝大家提前,並希望你能幫助我!