How to get an icon associated with specific Account from AccountManager.getAccounts()
Asked Answered
F

1

10

There is an icon displayed in account settings for each account. For Google account there is one icon, for Facebook another.

Is there a way of getting this icon from the code in application?

Fleisig answered 18/5, 2012 at 17:25 Comment(0)
F
9

Finally, I solved it:

    private Drawable getIconForAccount(Account account, AccountManager manager) {
        AuthenticatorDescription[] descriptions =  manager.getAuthenticatorTypes();
        PackageManager pm = getContext().getPackageManager();
        for (AuthenticatorDescription description: descriptions) {
            if (description.type.equals(account.type)) {
                return pm.getDrawable(description.packageName, description.iconId, null); 
            }
        }
        return null;
    }
Fleisig answered 19/5, 2012 at 15:37 Comment(3)
The ContactManager sample has an example on how to get the icon for an account if I remember correctly.Pertinacious
Thanks, but how do I get small icon??Novel
hey got it..use smallIconId insted of iconIdNovel

© 2022 - 2024 — McMap. All rights reserved.