Read Device ID / Device Serial / Hardware Serial via JavaScript in WebView Apps on Android 📲

Woman scanning qr code by mobile phone at home

The Device ID is uniquely assigned to your Android smartphone. This should actually uniquely identify the device, but this is not always the case: For some no-name devices (and custom ROMs), it is simply assigned to a placeholder ID or to “N/A” value. But if it is active on the device, it is used, for example, by the Android Debug Bridge (ADB) to distinguish between several simultaneously connected devices. Moreover, it can be used by app developers, including WebView app developers on Android. If we want to use a WebView in the app and have our app pass the Device ID to the page via JavaScript, then WebViewGold for Android Studio is the easiest way. Here’s how to do it:

  1. Download WebViewGold for Android
  2. Insert this HTML / JavaScript snippet into your website/web app:
<a href="get-uuid://">Get UDID</a>
<a href="#" onClick="alert(uuid);">Show UDID</a>