fisher3421 fisher3421 - 1 year ago 121
Android Question

Android lollipop contact color

How do select color of contact badge. What algorithm using?

enter image description here

Answer Source

It does not save. It uses the hashcode of the Contact name string to determine the color.

Example:

String name = "Harish";
int colors[] = new int[] { Color.RED, Color.GREEN, Color.BLUE};

int chosenColor = colors[Math.abs(name.hashCode()) % colors.length];

I learnt from this answer

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download