public class DbxAccountManager
extends java.lang.Object
Use getInstance
to get an instance
of DbxAccountManager
. Then call DbxAccountManager.getLinkedAccount()
to see if there's already
a linked Dropbox account. If that returns null
use DbxAccountManager.startLink(android.app.Activity, int)
to begin the
process of linking a user's Dropbox account.
Modifier and Type | Class and Description |
---|---|
static interface |
DbxAccountManager.AccountListener
Interface for receiving notifications of a new account being
linked or an existing account being unlinked.
|
static class |
DbxAccountManager.ConfigurationMismatchException
Thrown when
DbxAccountManager.getInstance(android.content.Context, java.lang.String, java.lang.String) was called with two different configurations
in the same application. |
static class |
DbxAccountManager.MultipleAccountsException
Thrown when the app attempts to link with a Dropbox account while
already linked.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SDK_VERSION_NAME
The human-readable version number for this SDK.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(DbxAccountManager.AccountListener l)
Adds an
DbxAccountManager.AccountListener which will be called
whenever a new account is linked or an existing account is unlinked. |
static DbxAccountManager |
getInstance(android.content.Context applicationContext,
java.lang.String appKey,
java.lang.String appSecret)
Initializes the Dropbox Sync API if necessary, and returns an object for
interacting with the Sync API.
|
DbxAccount |
getLinkedAccount()
Returns the
DbxAccount for the linked Dropbox account, if any. |
boolean |
hasLinkedAccount()
Returns whether this application is linked to a Dropbox account.
|
void |
removeListener(DbxAccountManager.AccountListener l)
Removes a listener previously added by a call to
DbxAccountManager.addListener(com.dropbox.sync.android.DbxAccountManager.AccountListener) . |
void |
startLink(android.app.Activity activity,
int callbackRequestCode)
Starts the authentication process to link a new account.
|
void |
startLink(android.app.Fragment fragment,
int callbackRequestCode)
Starts the authentication process to link a new account.
|
void |
startLink(android.support.v4.app.Fragment fragment,
int callbackRequestCode)
Starts the authentication process to link a new account.
|
void |
unlink()
Unlinks this app from the user's Dropbox account.
|
public static final java.lang.String SDK_VERSION_NAME
public static DbxAccountManager getInstance(android.content.Context applicationContext, java.lang.String appKey, java.lang.String appSecret)
applicationContext
- the context of the current application. Must be an
application context (getApplicationContext()
),
not just an Activity
or other context.appKey
- your Dropbox API app key.appSecret
- your Dropbox API app secret.DbxAccountManager.ConfigurationMismatchException
- if the app key or secret given
doesn't match an earlier call.public void startLink(android.app.Activity activity, int callbackRequestCode)
Activity.onActivityResult(int, int, android.content.Intent)
with the request
code you specify.
Note that if you're using an older Android SDK (prior to API 11), or
aren't using the
Android support library, you may see an error about the
type of the first argument to this method and the other overloads. You can
avoid this error using an explicit cast of the first argument to force this
method to be chosen. For instance: startLink((Activity)this, code)
activity
- the Activity that will be launched when linking is complete.callbackRequestCode
- the request code that will be passed to the given Activity's
Activity.onActivityResult(int, int, android.content.Intent)
when linking is complete.
This can be any value, which the API will simply pass through.DbxAccountManager.MultipleAccountsException
- if there's already an account linked.public void startLink(android.app.Fragment fragment, int callbackRequestCode)
Fragment.onActivityResult(int, int, android.content.Intent)
with the request
code you specify.
Note that if you're using an older Android SDK (prior to API 11), or
aren't using the
Android support library, you may see an error about the
type of the first argument to this method and the other overloads. You can
avoid this error using an explicit cast of the first argument to force this
method to be chosen. For instance: startLink((Fragment)this, code)
fragment
- the Fragment that will be launched when linking is complete.callbackRequestCode
- the request code that will be passed to the given Fragment's
Fragment.onActivityResult(int, int, android.content.Intent)
when linking is complete.
This can be any value, which the API will simply pass through.DbxAccountManager.MultipleAccountsException
- if there's already an account linked.public void startLink(android.support.v4.app.Fragment fragment, int callbackRequestCode)
Fragment.onActivityResult(int, int, android.content.Intent)
with
the request code you specify.
Note that if you're using an older Android SDK (prior to API 11), or
aren't using the
Android support library, you may see an error about the
type of the first argument to this method and the other overloads. You can
avoid this error using an explicit cast of the first argument to force this
method to be chosen. For instance: startLink((Fragment)this, code)
fragment
- the Fragment that will be launched when linking is complete.callbackRequestCode
- the request code that will be passed to the given Fragment's
Fragment.onActivityResult(int, int, android.content.Intent)
when
linking is complete. This can be any value, which the
API will simply pass through.DbxAccountManager.MultipleAccountsException
- if there's already an account linked.public void unlink()
public boolean hasLinkedAccount()
public DbxAccount getLinkedAccount()
DbxAccount
for the linked Dropbox account, if any. If no
account has been linked, this method will return null
.public void addListener(DbxAccountManager.AccountListener l)
DbxAccountManager.AccountListener
which will be called
whenever a new account is linked or an existing account is unlinked.
The listener will be called regardless of whether the account was
unlinked using DbxAccount.unlink()
or by the user on the Dropbox website.
Registering the same listener more than once will have no
additional effect. A single call to DbxAccountManager.removeListener(com.dropbox.sync.android.DbxAccountManager.AccountListener)
will still remove it.
public void removeListener(DbxAccountManager.AccountListener l)
DbxAccountManager.addListener(com.dropbox.sync.android.DbxAccountManager.AccountListener)
.