为什么在 Android 示例 BluetoothChat 应用程序中使用硬编码 UUID?

Why is a hardcoded UUID used in the Android Sample BluetoothChat application?

为什么要硬编码而不是像 SO post 中那样做?安全和不安全的 uuid 之间应该有什么区别?
这是一个 link 到 BluetoothService class,下面的代码所在。

// Unique UUID for this application
    private static final UUID MY_UUID_SECURE =
            UUID.fromString("fa87c0d0-afac-11de-8a39-0800200c9a66");
    private static final UUID MY_UUID_INSECURE =
            UUID.fromString("8ce255c0-200a-11e0-ac64-0800200c9a66");

您提供的 link 给出了如何找到设备 ID accepted answer gets the device id (IMEI, if a GSM phone), a per device unique identifier. This is not a UUID it can be transformed into one but that does not solve the problem Bluetooth Chat example application presents. The key to understanding why Bluetooth Chat is using a static UUID is to understand Bluetooth Service Discover Protocol. UUID's in SDP declare what protocol or service is available and are well known. If random UUID's were used and no one shared their meaning other devices would not know how to interact with that Bluetooth Service. This is roughly similar to putting a random schema in a URI. For example browsers know http and https (https is understood to use TLS) but not foop or barp. And, to represent a specific device Bluetooth uses a MAC Address 的答案,它是一个 48 位唯一编号。