Java tutorial
//package com.java2s; import android.annotation.TargetApi; import android.content.Context; import android.os.Build; import android.provider.Settings; import android.telephony.TelephonyManager; public class Main { /** * get app imei * @param context * @return */ @TargetApi(Build.VERSION_CODES.CUPCAKE) public static String getDeviceIMEI(Context context) { String deviceId; if (isPhone(context)) { TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); deviceId = telephony.getDeviceId(); } else { deviceId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); } return deviceId; } public static boolean isPhone(Context context) { TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (telephony.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE) { return false; } else { return true; } } }