Android has a way to get the name for a numeric UID using android.os.Process.getUidForName(String name)
. There is no method to get the numeric id from a UID name. This really ugly reflection will get the numeric UID/GID:
public static String getNameForUid(int id) {
try {
Class<?> clazz = Class.forName("libcore.io.Libcore");
Field field = clazz.getDeclaredField("os");
if (!field.isAccessible()) {
field.setAccessible(true);
}