I just tried this real quick on my Droid:
AccountManager mgr = AccountManager.get(this);
Account[] accts = mgr.getAccounts();
final int count = accts.length;
Account acct = null;
for(int i=0;i<count;i++) {
acct = accts[i];
Log.d("ACCT", "eclair account - name="+acct.name+",
type="+acct.type);
}
These are the results (masked :))
11-09 16:13:09.143: DEBUG/ACCT(2495): eclair account -
name=<myemail>@gmail.com, type=com.google
11-09 16:13:09.143: DEBUG/ACCT(2495): eclair account -
name=<myfacebook>@<facebook_email>.com, type=com.facebook.auth.login
11-09 16:13:09.143: DEBUG/ACCT(2495): eclair account -
name=<myworkmail>@<mycompany>.com, type=com.android.exchange
Do you understand how to actually use the returned Account objects?
It looks like you have to use an AccountManager instance and call the
getAuthToken method, but this keeps failing for me since I don't know
the authTokenType to pass as an input parameter. The Account object
itself has no other useful fields as far as I can tell.
Related is the AbstractAccountAuthenticator, where you're supposed to
be able to add authenticator types to appear on the phone (by default
on the Droid you get 3, Google, Facebook, and Exchange). Judging by
the documentation this would allow you to integrate your app into the
"quick contact bar" or whatever it's called, as well as use the
ContactsContract api to facilitate contact syncing, but there's no
examples around any of this stuff, just the documentation. I found
this thread about the ContactsContract, but it doesn't help if I can't
add my authenticator first:
http://groups.google.com/group/android-developers/browse_thread/thread/133816827efc8eb9/a571f095d9cb0199?lnk=raot
Anyone have any ideas?
On Nov 8, 9:21 pm, Micah <[email protected]> wrote:
> In Android 2.0 there is a new android.accounts.AccountManagerclass
> has a function getAccounts()
> see:http://developer.android.com/reference/android/accounts/AccountManage...()
>
> Unfortunately, as most of you know the SDK doesn't come with any of
> the Google Apps that utilize the Google Account associated with the
> phone (Gmail, Google Talk, Calendar, etc.). This means that when you
> call getAccounts in an emulator it returns an empty array.
>
> The *hope* is that Google has modified the Google apps shipped with
> Android 2.0 to use theAccountManagerAPI instead of whatever internal
> and super-secret-closed system they were using before. If this is the
> case, then 3rd party apps can hopefully gain access to a Google Auth
> token via theAccountManagerinstead of having to ask the user for
> their username / password.
>
> Unfortunately, the only phone that has android 2.0 on it to my
> knowledge is the Motorola Droid. So this is a call out to any
> developers that have access to that phone to please
> callAccountManager.getAccounts and let us know whether or not there is a
> Google Account on a production android device.
>
> If not then it appears that it will be up to 3rd party developers to
> write an Authenticator (ideally a free / open sourced one) that
> returns a Google Auth token (and prompts / stores user's Google
> credentials with the android.accounts API.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en