本文整理汇总了Java中org.altbeacon.beacon.Beacon类的典型用法代码示例。如果您正苦于以下问题:Java Beacon类的具体用法?Java Beacon怎么用?Java Beacon使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Beacon类属于org.altbeacon.beacon包,在下文中一共展示了Beacon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRangingResponse
import org.altbeacon.beacon.Beacon; //导入依赖的package包/类
private WritableMap createRangingResponse(Collection<Beacon> beacons, Region region) {
WritableMap map = new WritableNativeMap();
map.putString("identifier", region.getUniqueId());
map.putString("uuid", region.getId1() != null ? region.getId1().toString() : "");
WritableArray a = new WritableNativeArray();
for (Beacon beacon : beacons) {
WritableMap b = new WritableNativeMap();
b.putString("uuid", beacon.getId1().toString());
b.putInt("major", beacon.getId2().toInt());
b.putInt("minor", beacon.getId3().toInt());
b.putInt("rssi", beacon.getRssi());
b.putDouble("distance", beacon.getDistance());
b.putString("proximity", getProximity(beacon.getDistance()));
a.pushMap(b);
}
map.putArray("beacons", a);
return map;
}
示例2: didRangeBeaconsInRegion
import org.altbeacon.beacon.Beacon; //导入依赖的package包/类
/**
* Called from altbeacon Sdk when ranging is executed.
* @param collection beacons that are currently in range
* @param region region which all the scanned beacons received belongs to
*/
@Override public void didRangeBeaconsInRegion(Collection<Beacon> collection, Region region) {
List beaconsList = new ArrayList<>(collection);
if (regions.contains(region)){
List<OrchextraBeacon> beacons = beaconAndroidMapper.externalClassListToModelList(beaconsList);
beaconsController.onBeaconsDetectedInRegion(beacons, beaconRegionMapper.externalClassToModel(
region));
}
if (collection.size() > 0) {
for (Beacon beacon : collection) {
orchextraLogger.log("Beacon: " + beacon.getId1() + " major id:" + beacon.getId2()
+ " minor id: " + beacon.getId3());
}
}
}
示例3: onBeaconServiceConnect
import org.altbeacon.beacon.Beacon; //导入依赖的package包/类
@Override
public void onBeaconServiceConnect() {
mBeaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
if (beacons.size() > 0) {
mBeacon = beacons.iterator().next();
}
if (getActivity() != null) getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
loadBeacon();
}
});
}
});
try {
mBeaconManager.startRangingBeaconsInRegion(new Region(UNIQUE_RANGING_ID, mBeacon.getId1(), mBeacon.getId2(), mBeacon.getId3()));
} catch (RemoteException e) {
e.printStackTrace();
}
}
示例4: beaconsInRegion
import org.altbeacon.beacon.Beacon; //导入依赖的package包/类
public Observable<RxBeaconRange> beaconsInRegion() {
return startup()
.flatMap(new Function<Boolean, ObservableSource<RxBeaconRange>>() {
@Override
public ObservableSource<RxBeaconRange> apply(@NonNull Boolean aBoolean) throws Exception {
return Observable.create(new ObservableOnSubscribe<RxBeaconRange>() {
@Override
public void subscribe(@NonNull final ObservableEmitter<RxBeaconRange> objectObservableEmitter) throws Exception {
beaconManager.addRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> collection, Region region) {
objectObservableEmitter.onNext(new RxBeaconRange(collection, region));
}
});
beaconManager.startRangingBeaconsInRegion(getRegion());
}
});
}
});
}
示例5: onBeaconServiceConnect
import org.altbeacon.beacon.Beacon; //导入依赖的package包/类
@Override
public void onBeaconServiceConnect() {
beaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
if (beacons.size() > 0) {
Log.i(TAG, "The first beacon I see is about " + beacons.iterator().next().getDistance() + " meters away.");
}
}
});
try {
beaconManager.startRangingBeaconsInRegion(new Region("com.beacon.demo", null, null, null));
} catch (RemoteException e) {
e.printStackTrace();
}
}
示例6: createBasicSimulatedBeacons
import org.altbeacon.beacon.Beacon; //导入依赖的package包/类
/**
* Creates simulated beacons all at once.
*/
public void createBasicSimulatedBeacons(){
if (USE_SIMULATED_BEACONS) {
Beacon beacon1 = new AltBeacon.Builder().setId1("DF7E1C79-43E9-44FF-886F-1D1F7DA6997A")
.setId2("1").setId3("1").setRssi(-55).setTxPower(-55).build();
Beacon beacon2 = new AltBeacon.Builder().setId1("DF7E1C79-43E9-44FF-886F-1D1F7DA6997A")
.setId2("1").setId3("2").setRssi(-55).setTxPower(-55).build();
Beacon beacon3 = new AltBeacon.Builder().setId1("DF7E1C79-43E9-44FF-886F-1D1F7DA6997A")
.setId2("1").setId3("3").setRssi(-55).setTxPower(-55).build();
Beacon beacon4 = new AltBeacon.Builder().setId1("DF7E1C79-43E9-44FF-886F-1D1F7DA6997A")
.setId2("1").setId3("4").setRssi(-55).setTxPower(-55).build();
beacons.add(beacon1);
beacons.add(beacon2);
beacons.add(beacon3);
beacons.add(beacon4);
}
}
示例7: onBeaconServiceConnect
import org.altbeacon.beacon.Beacon; //导入依赖的package包/类
@Override
public void onBeaconServiceConnect() {
beaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
if (beacons.size() > 0) {
arrListBeacon.clear();
arrListBeacon.addAll(beacons);
showListBeacon();
}
}
});
try {
beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
} catch (RemoteException e) { }
}
示例8: showListBeacon
import org.altbeacon.beacon.Beacon; //导入依赖的package包/类
private void showListBeacon() {
runOnUiThread(new Runnable() {
public void run() {
Beacon beacon;
EditText editText = (EditText)RangingActivity.this.findViewById(R.id.rangingText);
int size = arrListBeacon.size();
editText.setText("Number of iBeacon devices: " + String.valueOf(size));
for(int i = 0; i < size; ++i) {
beacon = arrListBeacon.get(i);
editText.append("\n---------------------" +
"\n-UUID: " + beacon.getId1().toUuid().toString() +
"\n-Address: " + beacon.getBluetoothAddress() +
"\n-Major: " + beacon.getId2().toHexString() +
"\n-Minor: " + beacon.getId3().toHexString() +
"\n-TxPower: " + beacon.getTxPower() + " dBm" +
"\n-RSSI: " + beacon.getRssi() + " dBm" +
"\n-Distance: " + String.format("%.3f", beacon.getDistance()) + " m");
}
}
});
}
示例9: throwPush
import org.altbeacon.beacon.Beacon; //导入依赖的package包/类
private void throwPush(Beacon beacon) {
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.omnicrow_logo_small)
.setLargeIcon(BitmapFactory.decodeResource(getResources(),
R.drawable.omnicrow_logo))
.setContentTitle("BEACON FOUND")
.setContentText(beacon.getBluetoothName());
int mNotificationId = 001;
// Gets an instance of the NotificationManager service
NotificationManager mNotifyMgr =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// Builds the notification and issues it.
mNotifyMgr.notify(mNotificationId, notificationBuilder.build());
}
示例10: didRangeBeaconsInRegion
import org.altbeacon.beacon.Beacon; //导入依赖的package包/类
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
if (beacons != null && beacons.size() > 0 && region != null) {
RegionName regName = RegionName.parseString(region.getUniqueId());
if (regName.isApplicationRegion()) {
if (regName.getEventType() == ActionBeacon.EventType.EVENT_NEAR_YOU) {
Iterator<Beacon> iterator = beacons.iterator();
while (iterator.hasNext()) {
Beacon beacon = iterator.next();
// TrackedBeacon tracked = mDataManager.getBeacon(regName.getBeaconId());
// mDataManager.updateBeaconDistance(regName.getBeaconId(), beacon.getDistance());
// if (tracked != null && BeaconUtil.isInProximity(IManagedBeacon.ProximityType.FAR, tracked.getDistance())) {
// if (BeaconUtil.isInProximity(IManagedBeacon.ProximityType.NEAR, beacon.getDistance())
// || BeaconUtil.isInProximity(IManagedBeacon.ProximityType.IMMEDIATE, beacon.getDistance())) {
//
// Intent intent = new Intent();
// intent.setAction(Constants.NOTIFY_BEACON_NEAR_YOU_REGION);
// intent.putExtra("REGION", (Parcelable)region);
// getApplicationContext().sendOrderedBroadcast(intent, null);
// }
// }
}
}
}
}
}
示例11: logEddystoneTelemetry
import org.altbeacon.beacon.Beacon; //导入依赖的package包/类
/**
* log Eddystome TLM data.
*
* @param beacon
*/
private void logEddystoneTelemetry(Beacon beacon) {
// Do we have telemetry data?
if (beacon.getExtraDataFields().size() > 0) {
long telemetryVersion = beacon.getExtraDataFields().get(0);
long batteryMilliVolts = beacon.getExtraDataFields().get(1);
long pduCount = beacon.getExtraDataFields().get(3);
long uptime = beacon.getExtraDataFields().get(4);
tele_versTV.append("" + telemetryVersion);
uptimeTV.append("" + uptime);
batteryTV.append("" + batteryMilliVolts);
tx_countTV.append("" + pduCount);
} else {
eddystoneTlmHeader.setVisibility(View.GONE);
tele_versTV.setVisibility(View.GONE);
uptimeTV.setVisibility(View.GONE);
batteryTV.setVisibility(View.GONE);
uptimeTV.setVisibility(View.GONE);
tx_countTV.setVisibility(View.GONE);
}
}
示例12: didRangeBeaconsInRegion
import org.altbeacon.beacon.Beacon; //导入依赖的package包/类
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
Iterator<Beacon> iterator = beacons.iterator();
while (iterator.hasNext()) {
//EditText editText = (EditText)RangingActivity.this.findViewById(R.id.rangingText);
Beacon beacon = iterator.next();
Timber.d("beacon %s is about: %f meters away.", beacon.toString(), beacon.getDistance());
deviceFound(beacon);
if (backgroundPowerSaver.isScannerActivityResumed()) {
scanner.onNext(devices);
} else if (SystemClock.elapsedRealtime() - backgroundPowerSaver.getScannerActivityDestroyedTimestamp() >
ThunderBoardPowerSaver.DELAY_NOTIFICATIONS_TIME_THRESHOLD
&& backgroundPowerSaver.isApplicationBackgrounded()) {
Timber.d("Sending notification.");
sendNotification(beacon);
}
}
}
示例13: broadcastAsBeacon
import org.altbeacon.beacon.Beacon; //导入依赖的package包/类
public void broadcastAsBeacon() {
Beacon beacon = new Beacon.Builder()
.setId1("2f234454-cf6d-4a0f-adf2-f4911ba9ffa6")
.setId2("1")
.setId3("2")
.setManufacturer(0x0118) // Radius Networks. Change this for other beacon layouts
.setTxPower(-59)
.setDataFields(Arrays.asList(new Long[]{0l})) // Remove this for beacon layouts without d: fields
.build();
// Change the layout below for other beacon types
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(context, beaconParser);
beaconTransmitter.startAdvertising(beacon, new AdvertiseCallback() {
@Override
public void onStartFailure(int errorCode) {
Log.e("Class", "Advertisement start failed with code: " + errorCode);
}
@Override
public void onStartSuccess(AdvertiseSettings settingsInEffect) {
Log.i("class", "Advertisement start succeeded.");
}
});
}
示例14: createBasicSimulatedBeacons
import org.altbeacon.beacon.Beacon; //导入依赖的package包/类
/**
* Creates simulated beacons all at once.
*/
public void createBasicSimulatedBeacons(){
if (USE_SIMULATED_BEACONS) {
Beacon beacon1 = new AltBeacon.Builder().setId1("DF7E1C79-43E9-44FF-886F-1D1F7DA6997A")
.setId2("1").setId3("1").setRssi(-55).setTxPower(-55).build();
Beacon beacon2 = new AltBeacon.Builder().setId1("DF7E1C79-43E9-44FF-886F-1D1F7DA6997A")
.setId2("1").setId3("2").setRssi(-55).setTxPower(-55).build();
Beacon beacon3 = new AltBeacon.Builder().setId1("DF7E1C79-43E9-44FF-886F-1D1F7DA6997A")
.setId2("1").setId3("3").setRssi(-55).setTxPower(-55).build();
Beacon beacon4 = new AltBeacon.Builder().setId1("DF7E1C79-43E9-44FF-886F-1D1F7DA6997A")
.setId2("1").setId3("4").setRssi(-55).setTxPower(-55).build();
beacons.add(beacon1);
beacons.add(beacon2);
beacons.add(beacon3);
beacons.add(beacon4);
}
}
示例15: onBeaconServiceConnect
import org.altbeacon.beacon.Beacon; //导入依赖的package包/类
@Override
public void onBeaconServiceConnect() {
beaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
if (beacons.size() > 0) {
//EditText editText = (EditText)RangingActivity.this.findViewById(R.id.rangingText);
Beacon firstBeacon = beacons.iterator().next();
logToDisplay("The first beacon "
+ firstBeacon.toString() + " is about "
+ firstBeacon.getDistance() + " meters away.");
}
}
});
try {
beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
} catch (RemoteException e) { }
}