谷歌有一個示例Android應用程序,可以讓你註冊與他們的後端信標。你可以看到調用registerBeacon
here的代碼。
實際註冊過程的帖子JSON到谷歌的服務器,和JSON代來自com.google.sample.beaconservice.Beacon
類在這個項目here.
如果你看一下這條線,你會看到,它的標識,從一個字節數組轉換至底座64與:
JSONObject advertisedId = new JSONObject()
.put("type", type)
.put("id", Utils.base64Encode(id));
因此,對於一個埃迪斯通UID與0x010203040506070809 10字節的名稱空間和0x0a0b0c0d0e0f的6字節實例,則可以底座64編碼的標識符這樣的:
byte[] eddystoneBeaconId = new byte[] {(byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x01a (byte) 0x0b, (byte) 0x0c, (byte) 0x0d, (byte) 0x0e, (byte) 0x0f };
String base64EncodedEddystoneBeaconId = android.util.Base64.encodeToString(id, android.util.Base64.DEFAULT);
這就是票!謝謝。 –