Flo
Flo

Reputation: 1499

Android Account Management - How to create different types of accounts?

Sorry for the strange title, but I don't know how to best summarize my question. So I best explain it with pictures.

While the google system account can have multiple accounts (all listed under 'Accounts'), the viber account seems like it can only have one account entry. It directly shows the sync settings while in google they are hidden away with one more click.

google account

viber account

I know how to create an account authenticator that manages accounts like the google account. A good tutorial can be found here. However, how can I create an account authenticator that manages viber-like accounts and how are they different?

Upvotes: 2

Views: 983

Answers (1)

Ali Nem
Ali Nem

Reputation: 5530

If you would like to allow only one account per account type (say Viber), then you should check if any account of that type exists first. To do this, the following can be used:

AccountManager accountManager = AccountManager.get(context);
Account[] accounts = accountManager.getAccountsByType(yourAccountType);
if(accounts.length!=0) {
/* An account of that account type exists. Do not allow adding further accounts of this type */
}

Upvotes: 1

Related Questions