Java tutorial
//package com.java2s; import android.telephony.TelephonyManager; import android.text.TextUtils; import java.util.UUID; public class Main { public static String getDeviceId(TelephonyManager tm) { String id = tm.getSubscriberId(); if (TextUtils.isEmpty(id)) { id = tm.getDeviceId(); } if (TextUtils.isEmpty(id)) { id = UUID.randomUUID().toString(); } return id; } }