All communication with the Evernote Cloud API uses the
EvernoteSession object. Looking at the
HelloEDAM.java file in the sample application included with the Evernote SDK for Android, we can see how to initialize and use
Beginning just inside the declaration of the
HelloEDAM class, you'll find these lines of code:
CONSUMER_SECRET are the two parts of your Evernote API key. Replace the placeholder text with your actual key and secret.
EVERNOTE_HOST is the server with which your app will be interacting. While your app is in development, this host will be
EvernoteSession.HOST_SANDBOX. Once your app is ready for production use and you've had your Evernote API key activated in our production environment, you'll need to change that value to
EvernoteSession.HOST_CHINA if you're connecting to the Yinxiang Biji (Evernote China) service.
At the bottom of the
onCreate method, you'll see a call to
setupSession() whose definition looks like this:
Under the hood,
EvernoteSession is a singleton object; if an instance has already been created when
getInstance is called, that instance will be returned. Otherwise, a new instance is created and returned.
The constructor takes four parameters:
this, in this case since
Activity is a descendent of
Context in the
android class hierarchy.
- A consumer key (which we have defined as
- A consumer secret (
CONSUMER_SECRET in the sample app).
- The host we'll be connecting to (
EvernoteSession has been initialized—as
mEvernoteSession in our app—we're almost ready to start making calls to the API. First, though, we need to authenticate.