Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 527
Prizoff Avatar asked May 18 '12 17:05

Prizoff


1 Answers

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;
    }
like image 138
Prizoff Avatar answered Oct 29 '22 11:10

Prizoff