Posts

Showing posts with the label Serial Number

Android: How To Programmatically Access The Device Serial Number Shown In The AVD Manager (API Version 8)

Answer : This is the hardware serial number. To access it on Android Q (>= SDK 29) android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE is required. Only system apps can require this permission. If the calling package is the device or profile owner then the READ_PHONE_STATE permission suffices. Android 8 and later (>= SDK 26) use android.os.Build.getSerial() which requires the dangerous permission READ_PHONE_STATE. Using android.os.Build.SERIAL returns android.os.Build.UNKNOWN. Android 7.1 and earlier (<= SDK 25) and earlier android.os.Build.SERIAL does return a valid serial. It's unique for any device. If you are looking for possibilities on how to get/use a unique device id you should read here. For a solution involving reflection without requiring a permission see this answer. Up to Android 7.1 (SDK 25) Until Android 7.1 you will get it with: Build.SERIAL From Android 8 (SDK 26) On Android 8 (SDK 26) and above, this field will return UN...