public final class EvernoteSession
extends java.lang.Object
EvernoteSession.Builder class and call asSingleton(). After that
initiate authentication at an appropriate time:
EvernoteSession evernoteSession = new EvernoteSession.Builder(this)
.setEvernoteService(EvernoteSession.EvernoteService.PRODUCTION)
.setSupportAppLinkedNotebooks(SUPPORT_APP_LINKED_NOTEBOOKS)
.build(consumerKey, consumerSecret)
.asSingleton();
if (!session.isLoggedIn()) {
session.authenticate(...);
}
Later, you can make any Evernote API calls that you need by obtaining a
NoteStore.Client from the session and using the session's auth token:
NoteStore.client noteStore = session.createNoteStoreClient(); Notebook notebook = noteStore.getDefaultNotebook(session.getAuthToken());
| Modifier and Type | Class and Description |
|---|---|
static class |
EvernoteSession.Builder
Builder class to construct an
EvernoteSession. |
static class |
EvernoteSession.EvernoteService
Evernote Service to use with the bootstrap profile detection.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
HOST_CHINA |
static java.lang.String |
HOST_PRODUCTION |
static java.lang.String |
HOST_SANDBOX |
static int |
REQUEST_CODE_LOGIN
The used request code when you launch authentication process from a
Activity. |
static java.lang.String |
SCREEN_NAME_INTERNATIONAL |
static java.lang.String |
SCREEN_NAME_YXBIJI |
| Modifier and Type | Method and Description |
|---|---|
EvernoteSession |
asSingleton()
Sets this session instance as singleton.
|
void |
authenticate(FragmentActivity activity)
Recommended approach to authenticate the user.
|
void |
authenticate(FragmentActivity activity,
EvernoteLoginFragment fragment) |
android.content.Context |
getApplicationContext() |
AuthenticationResult |
getAuthenticationResult()
Get the authentication information returned by a successful
OAuth authentication to the Evernote web service.
|
java.lang.String |
getAuthToken()
Get the authentication token that is used to make API calls
though a NoteStore.Client.
|
EvernoteClientFactory |
getEvernoteClientFactory()
Returns a factory to create various clients and helper objects to get access to the Evernote API.
|
protected EvernoteSession.EvernoteService |
getEvernoteService() |
static EvernoteSession |
getInstance() |
boolean |
isLoggedIn()
Check whether the session has valid authentication information
that will allow successful API calls to be made.
|
boolean |
logOut()
Clears all stored session information.
|
protected void |
setAuthenticationResult(AuthenticationResult authenticationResult) |
void |
setEvernoteClientFactoryBuilder(EvernoteClientFactory.Builder builder) |
public static final java.lang.String HOST_SANDBOX
public static final java.lang.String HOST_PRODUCTION
public static final java.lang.String HOST_CHINA
public static final java.lang.String SCREEN_NAME_YXBIJI
public static final java.lang.String SCREEN_NAME_INTERNATIONAL
public static final int REQUEST_CODE_LOGIN
Activity. Override
Activity.onActivityResult(int, int, Intent) to receive the result.public static EvernoteSession getInstance()
protected EvernoteSession.EvernoteService getEvernoteService()
public EvernoteClientFactory getEvernoteClientFactory()
setEvernoteClientFactoryBuilder(EvernoteClientFactory.Builder) you can exchange
the builder.public void setEvernoteClientFactoryBuilder(EvernoteClientFactory.Builder builder)
builder - The new builder returning EvernoteClientFactorys in getEvernoteClientFactory().public android.content.Context getApplicationContext()
public java.lang.String getAuthToken()
isLoggedIn()
is false.public AuthenticationResult getAuthenticationResult()
public void authenticate(FragmentActivity activity)
FragmentActivity should implement EvernoteLoginFragment.ResultCallback to receive
the authentication result. Alternatively you can extend EvernoteLoginFragment and override
EvernoteLoginFragment.onLoginFinished(boolean).activity - The FragmentActivity holding the progress dialog.public void authenticate(FragmentActivity activity,
EvernoteLoginFragment fragment)
authenticate(FragmentActivity)public EvernoteSession asSingleton()
getInstance() to get
this session.protected void setAuthenticationResult(AuthenticationResult authenticationResult)
public boolean isLoggedIn()
public boolean logOut()
true if the user successfully logged out, false if the user wasn't
logged in.isLoggedIn()