get Identifier for a device - Android android.telephony

Android examples for android.telephony:TelephonyManager

Description

get Identifier for a device

Demo Code

import java.util.UUID;

import android.content.Context;
import android.telephony.TelephonyManager;

public class Main {

  public static String getIdentifier(Context context) {

    final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    final String tmDevice, tmSerial, androidId;
    tmDevice = "" + tm.getDeviceId();
    tmSerial = "" + tm.getSimSerialNumber();
    androidId = "" + android.provider.Settings.Secure.getString(context.getContentResolver(),
        android.provider.Settings.Secure.ANDROID_ID);
    UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
    return deviceUuid.toString();

  }/*from ww  w  .  ja v a 2 s  .c o  m*/

}

Related Tutorials