Java tutorial
//package com.java2s; //License from project: Open Source License import android.graphics.Color; public class Main { public static String getColorHexString(int color) { String colorHex = "#"; String a = Integer.toHexString(Color.alpha(color)); if (a.length() == 1) a = "0" + a; String r = Integer.toHexString(Color.red(color)); if (r.length() == 1) r = "0" + r; String g = Integer.toHexString(Color.green(color)); if (g.length() == 1) g = "0" + g; String b = Integer.toHexString(Color.blue(color)); if (b.length() == 1) b = "0" + b; colorHex += a + r + g + b; return colorHex; } }