Question

What is the simplest way to create a custom account on Android? So far I've read the documentation: Creating a Custom Account Type, but it certainly didn't help a lot (too vague info). I tried reading the example from LastFm but certainly they did things a bit too much elaborately which I quite didn't understand well since I'm just an Android beginner with the accounts. I know its not as simple as calling:

final Account account = new Account(mUsername, your_account_type);
mAccountManager.addAccountExplicitly(account, mPassword, null);

because this would trow an exception.

So far I understood that I need to use an AccountAuthenticatorActivity and a service that works as authenticator. Any help that would point me in the right direction would be much appreciated.

Était-ce utile?

La solution

Did you checkout the sample sync adapter app? It's a little complicated and convoluted, but if you stick with it you can get things working. I've got a slightly simpler implementation in an android app I've been working on if you want to check that out as well.

Accounts are one of those things that I really wish android made a lot simpler. It used to be a poorly documented yet critical feature. They documentation seems to be getting better though.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top