1

I want to use AccountManager in Android, to verify a com.google account. I've already know how to get the account, But I've got several questions,

  1. If the account is not in AccountManager, and the account self is under com.google domain, then how can I add it?
  2. How AccountManager manage tokens? It retrieves tokens automatically, or I need to do it manually?
  3. I'm trying to use Google Reader API with ClientLogin, then I may need password for the first time. If some com.google accounts are stored previously by other apps, can I use them to get the password?

Edit on 2011.08.20

To clarify the question, what I want to ask it this,

  1. Google applications on Android has its own routine to verify Google accounts, and I want to know whether it's possible to call the routine created by Google applications, and get my own authority?
  2. If there's no Google Account on Android phone, how can I add an account, which will be accepted by Google applications later?
Davidsun
  • 721
  • 6
  • 13
  • Can you elaborate on "verify a com.google account"? Not quite clear what you mean there. – Roman Nurik Aug 18 '11 at 02:36
  • I was a little confused when reading this question and answer but this next link was really helpful. So for anyone who still cares: http://code.google.com/apis/tasks/articles/oauth-and-tasks-on-android.html – hwrdprkns Jan 06 '12 at 20:34

1 Answers1

4

If the account is not in AccountManager, and the account self is under com.google domain, then how can I add it?

If you simply want to have, for example, a button that lets the user add a Google account, consider invoking the ADD_ACCOUNT intent. Another, more advanced, option is to use AccountManager.addAccount.

How AccountManager manage tokens? It retrieves tokens automatically, or I need to do it manually?

The system manages tokens. Well, actually, applications register 'authenticators' which manage tokens for their corresponding service. An authenticator for Google accounts comes preloaded with most Android devices, and third party apps like Twitter add their own authenticators when installed. Apps that want to use Google accounts can request authentication tokens using AccountManager.getAuthToken.

I'm trying to use Google Reader API with ClientLogin, then I may need password for the first time. If some com.google accounts are stored previously by other apps, can I use them to get the password?

Your app should never ask the user for her Google password. Use the relevant AccountManager methods to request an auth token for Reader. Unfortunately, since Google Reader doesn't have a public API I can't assist further.

Roman Nurik
  • 29,665
  • 7
  • 84
  • 82
  • Thanks for your reply, it helps a lot, but I'm still having problems. Actually, for apps made by Google, they've got the same routine to take the auth. How can I call that routine from my app? – Davidsun Aug 20 '11 at 01:23
  • This, or something like OAuth, are the only recommended ways of getting auth tokens for a Google account. – Roman Nurik Aug 21 '11 at 15:18