I need to emulate beacon. I use devices
- Android 6.0 (LG, Nexus 5)
- Android 9.0 (Honor 10)
In my app/build.gradle:
implementation 'org.altbeacon:android-beacon-library:2.16.3'
In my activity:
public void onClickGenerateBeacon(View view) {
Beacon beacon = new Beacon.Builder()
.setId1(UUID.randomUUID().toString())
.setId2("1")
.setId3("2")
.setManufacturer(0x0118)
.setTxPower(-59)
.setDataFields(Arrays.asList(new Long[]{0l}))
.build();
BluetoothManager btManager = (BluetoothManager) getSystemService(BLUETOOTH_SERVICE);
BluetoothAdapter btAdapter = btManager.getAdapter();
boolean isSupported = false;
if (btAdapter.isEnabled())
isSupported = btAdapter.isMultipleAdvertisementSupported();
if (isSupported) {
BeaconParser beaconParser = new BeaconParser().setBeaconLayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25");
BeaconTransmitter beaconTransmitter = new BeaconTransmitter(getApplicationContext(), beaconParser);
beaconTransmitter.startAdvertising(beacon);
}
}
But isSupported is always false
. And as result not execute:
new BeaconParser().setBeaconLayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25");
How I can fix this? Is it possible to emulate beacons by this lib or maybe has another approach?