<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
/**
* IMEI 1号
* @param context
* @return
*/
public static String getIMEI_1(Context context){
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
return tm != null ? tm.getDeviceId() : null;
}
/**
* IMEI 2号
* @param context
* @return
*/
public static String getIMEI_2(Context context){
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
Class clazz = tm.getClass();
try {
Method getImei = clazz.getDeclaredMethod("getImei",int.class);
return getImei.invoke(tm,1).toString();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return null;
}