String imei = android.os.SystemProperties.get(android.telephony.TelephonyProperties.PROPERTY_IMSI);
with permission
android.permission.READ_PHONE_STATE
Since SystemProperties is a hidden class in Android, you can access it with reflection:
/**
* Get the value for the given key.
* @return an empty string if the key isn't found
*/
public static String get(Context context, String key) {
String ret = "";
try {
ClassLoader cl = context.getClassLoader();
@SuppressWarnings("rawtypes")
Class SystemProperties = cl.loadClass("android.os.SystemProperties");
//Parameters Types
@SuppressWarnings("rawtypes")
Class[] paramTypes= new Class[1];
paramTypes[0]= String.class;
Method get = SystemProperties.getMethod("get", paramTypes);
//Parameters
Object[] params = new Object[1];
params[0] = new String(key);
ret = (String) get.invoke(SystemProperties, params);
} catch(Exception e) {
ret = "";
//TODO : Error handling
}
return ret;
}