code: private static String getDeviceSerialNumber() {
          // We're using the Reflection API because Build.SERIAL is only available
          // since API Level 9 (Gingerbread, Android 2.3).
          try {
              return (String) Build.class.getField("SERIAL").get(null);
          } catch (Exception ignored) {
              return null;
          }
      }
docs: Gets the hardware serial number of this device.
  
  @return serial number or {@code null} if not available.