diff options
author | Trevor Johns <trevorjohns@google.com> | 2013-10-22 20:41:07 -0700 |
---|---|---|
committer | Trevor Johns <trevorjohns@google.com> | 2013-10-23 11:28:20 -0700 |
commit | 2ecd0586218cc1269da837a8ef155ec8089d1124 (patch) | |
tree | aff4c1a8f4207e6664e811450720980791458ead /common | |
parent | 3c5ea8095f3982e4856e4c71ae9812c291aad98a (diff) | |
download | android-2ecd0586218cc1269da837a8ef155ec8089d1124.tar.gz |
GenericAccountService: Allow arbitrary account types
Removed hardcoded account type from GenericAccountService, to support
better reusability between projects.
Change-Id: I95f0626cebceb097fa0136c85ac0ef998987b3a6
Diffstat (limited to 'common')
-rw-r--r-- | common/src/java/com/example/android/common/accounts/GenericAccountService.java | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/common/src/java/com/example/android/common/accounts/GenericAccountService.java b/common/src/java/com/example/android/common/accounts/GenericAccountService.java index 9480023b..0cd499a8 100644 --- a/common/src/java/com/example/android/common/accounts/GenericAccountService.java +++ b/common/src/java/com/example/android/common/accounts/GenericAccountService.java @@ -29,17 +29,23 @@ import android.util.Log; public class GenericAccountService extends Service { private static final String TAG = "GenericAccountService"; - private static final String ACCOUNT_TYPE = "com.example.android.network.sync.basicsyncadapter"; - public static final String ACCOUNT_NAME = "sync"; + public static final String ACCOUNT_NAME = "Account"; private Authenticator mAuthenticator; /** * Obtain a handle to the {@link android.accounts.Account} used for sync in this application. * + * <p>It is important that the accountType specified here matches the value in your sync adapter + * configuration XML file for android.accounts.AccountAuthenticator (often saved in + * res/xml/syncadapter.xml). If this is not set correctly, you'll receive an error indicating + * that "caller uid XXXXX is different than the authenticator's uid". + * + * @param accountType AccountType defined in the configuration XML file for + * android.accounts.AccountAuthenticator (e.g. res/xml/syncadapter.xml). * @return Handle to application's account (not guaranteed to resolve unless CreateSyncAccount() * has been called) */ - public static Account GetAccount() { + public static Account GetAccount(String accountType) { // Note: Normally the account name is set to the user's identity (username or email // address). However, since we aren't actually using any user accounts, it makes more sense // to use a generic string in this case. @@ -47,7 +53,7 @@ public class GenericAccountService extends Service { // This string should *not* be localized. If the user switches locale, we would not be // able to locate the old account, and may erroneously register multiple accounts. final String accountName = ACCOUNT_NAME; - return new Account(accountName, ACCOUNT_TYPE); + return new Account(accountName, accountType); } @Override |