Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.ContentResolver; import android.provider.Settings.System; public class Main { public static String getDeviceId(ContentResolver contentResolver) { String androidId = System.getString(contentResolver, System.ANDROID_ID); String androidBase = "androidDeviceId_"; if (androidId == null) { // This happens when running in the Emulator final String emulatorId = "android-RunningAsTestingDeleteMe"; return emulatorId; } String deviceId = androidBase.concat(androidId); return deviceId; } }