0
我想利用圖書館iBeacon顯示檢測定位應用程序,但不是在燈塔工具
compile 'org.altbeacon:android-beacon-library:[email protected]'
代碼
if (mBeaconTransmitter != null) {
mBeaconTransmitter.stopAdvertising();
}
BeaconParser beaconParser=new BeaconParser();
mBeaconTransmitter = new BeaconTransmitter(getApplicationContext(), new BeaconParser().setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
int flag= mBeaconTransmitter.checkTransmissionSupported(this);
Log.v("@@@WWe"," BEacon Test "+flag);
Beacon beacon = new Beacon.Builder()
.setId1("2f234454-cf6d-4a0f-adf2-f4911ba9ffa6")
.setId2(majorID)//Major
.setId3(minorID)//Minor
.setBluetoothName("Vyas Pratik")
.setBeaconTypeCode(533)
.setManufacturer(0x0075) // Choose a number of 0x00ff or less as some devices cannot detect beacons with a manufacturer code > 0x00ff
.setTxPower(-59)
.setMultiFrameBeacon(true)
.build();
// .setId2(minorID)//Major Try
// .setId3(majorID)//Minor Try
//.setBluetoothAddress(bluetoothManager.getAdapter().getAddress())
// .setDataFields(Arrays.asList(new Long[]{0l}))
mBeaconTransmitter.startAdvertising(beacon, new AdvertiseCallback() {
@Override
public void onStartSuccess(AdvertiseSettings settingsInEffect) {
super.onStartSuccess(settingsInEffect);
Log.v("@@@WWe"," Sucess "+settingsInEffect.toString());
}
@Override
public void onStartFailure(int errorCode) {
super.onStartFailure(errorCode);
Log.v("@@@WWe"," Error "+String.valueOf(errorCode));
}
});
但是傳輸從設備使其成爲一個iBeacon顯示主要和次要ID,我的燈塔使用此代碼在「定位」應用程序中檢測到,但未在「信標工具」應用程序/附近(Google應用程序)中檢測到。請引導我。
感謝
高興你發現了它。是的,使用iBeacon,您必須將製造商代碼設置爲Apple的代碼。 – davidgyoung
是的,設置製造商代碼和正確的uuid使我的代碼工作 –