【发布时间】:2020-05-16 19:59:08
【问题描述】:
我使用以下代码在我的 Android 设备上作为 Eddystone 传输;
try {
byte[] urlBytes = UrlBeaconUrlCompressor.compress("http://www.****.com");
Identifier encodedUrlIdentifier = Identifier.fromBytes(urlBytes, 0, urlBytes.length, false);
ArrayList<Identifier> identifiers = new ArrayList<Identifier>();
identifiers.add(encodedUrlIdentifier);
Beacon beacon = new Beacon.Builder()
.setBluetoothName("devicename")
.setIdentifiers(identifiers)
.setManufacturer(0x0118)
.setTxPower(-59)
.build();
BeaconParser beaconParser = new BeaconParser()
.setBeaconLayout(BeaconParser.EDDYSTONE_URL_LAYOUT);
BeaconTransmitter beaconTransmitter = new BeaconTransmitter(getApplicationContext(), beaconParser);
beaconTransmitter.startAdvertising(beacon);
} catch (MalformedURLException e) {
Log.d("ww", "That URL cannot be parsed");
}
扫描设备时我无法获取 beacon.getBluetoothName()。能不能加个名字。我使用 .setBluetoothName("devicename") 添加但扫描时未显示。它返回 null。
【问题讨论】:
标签: android altbeacon eddystone