public String getEnrollmentSpecificId ()
It returns an enrollment-specific identifier of this device, which is guaranteed to be the same value for the same device, enrolled into the same organization by the same managing app. This identifier uniquely identifies individual devices within the same organization. The identifier would be consistent even if the work profile is removed and enrolled again (to the same organization), or the device is factory reset and re-enrolled.
Usage:
fun getEnrollmentSpecificId(): String {
val policy = getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
try {
policy.enrollmentSpecificId
} catch (securityException: SecurityException) {
print(securityException.message)
""
}
} else {
""
}
}