Java tutorial
//package com.java2s; import java.util.UUID; import android.content.Context; import android.os.Build; public class Main { /** * get a unique hash of the device. * * @return a unique hash of the device. */ public static String getDeviceId(Context ctx) { if (ctx == null) { return null; } String androidId = "" + android.provider.Settings.Secure.getString( ctx.getApplicationContext().getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); String deviceName = getDeviceName(); UUID deviceUuid = new UUID(androidId.hashCode(), (long) deviceName.hashCode() << 32 | deviceName.hashCode()); String deviceId = deviceUuid.toString().replace("-", ""); return deviceId; } /** * Retrieves the information(deviceId, sim serial number etc) of the device on which app is running * * @return the deviceID, if no deviceID is available the Android build MODEL is returned. */ public static String getDeviceName() { final String deviceName; String manufacturer = "" + Build.MANUFACTURER; String model = Build.MODEL; if (model.startsWith(manufacturer)) { deviceName = model; } else { deviceName = manufacturer + " " + model; } return deviceName; } }