I've implemented my AccountManager authenticator and the service and the whole deal and it all seems to be working fine.
There is, however, one little problem: I only want a single account for my app to exist in account manager, but can't quite seem to find a way to limit this.
Is my only solution to do a search and delete the current accounts (by type) before adding the new account?
My current code:
private void removeAccounts()
{
Account [] accounts = mAcctMgr.getAccountsByType (mAccountType);
if (accounts.length == 0) return;
final Handler handler = new Handler ();
AccountManagerCallback<Boolean> callback = new AccountManagerCallback<Boolean>()
{
@Override
public void run(AccountManagerFuture<Boolean> arg0)
{
// nada
}
};
for (Account a : accounts) {
mAcctMgr.removeAccount (a, callback, handler);
}
}
I don't by any means call this an elegant solution, but at the moment seems to be the only thing that works.