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

后端 未结 1 1869
甜味超标
甜味超标 2021-02-20 11:30

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

1条回答
  •  深忆病人
    2021-02-20 12:00

    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;
        }
    

    0 讨论(0)
提交回复
热议问题