Problem Using Android.accounts Authenticator
Solution 1:
I've worked it out.
It turns out that it's a bug in Android 2.0. If you add an account to the AccountManager, you must also provide a SynAdapter to the account, under the Android 2.0 platform. But things are all right under Android 2.1 and above.
This is a known issue, please refer to: http://code.google.com/p/android/issues/detail?id=5009 and AccountManager without a SyncAdapter?
Solution 2:
Accountaccount=newAccount(username, AuthConstants.ACCOUNT_TYPE);
if (am.addAccountExplicitly(account, password, null)) {
result = newBundle();
ContentResolver.setSyncAutomatically(account, DB.AUTHORITY, true);
result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
result.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type);
return result;
}
I am using this code in one of my apps which works perfectly. the key here is the AccountAuthenticatorActivity that should set the authentication result bundle which should be registered (the sync adapter from android developers has this.
also here is my addAccount method for the accountAuthentication service
@Overridepublic Bundle addAccount(AccountAuthenticatorResponse response,
String accountType, String authTokenType, String[] requiredFeatures,
Bundle options) {
finalIntentintent=newIntent(mContext, LoginScreen.class);
intent.putExtra(LoginScreen.PARAM_AUTHTOKEN_TYPE,
authTokenType);
intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE,
response);
finalBundlebundle=newBundle();
bundle.putParcelable(AccountManager.KEY_INTENT, intent);
return bundle;
}
UPDATE
Here is a link i used. this is a good project. i believe it is from the last.fm android app. it also has the source code open on git i believe. so try to compare with that.
PERMISSIONS
<uses-permissionandroid:name="android.permission.GET_ACCOUNTS" /><uses-permissionandroid:name="android.permission.MANAGE_ACCOUNTS" /><uses-permissionandroid:name="android.permission.AUTHENTICATE_ACCOUNTS" /><uses-permissionandroid:name="android.permission.READ_SYNC_SETTINGS" /><uses-permissionandroid:name="android.permission.WRITE_SYNC_SETTINGS" /><uses-permissionandroid:name="android.permission.WRITE_SETTINGS" /><uses-permissionandroid:name="android.permission.WRITE_SECURE_SETTINGS" />
Post a Comment for "Problem Using Android.accounts Authenticator"