本文整理匯總了Java中org.altbeacon.beacon.Region類的典型用法代碼示例。如果您正苦於以下問題:Java Region類的具體用法?Java Region怎麽用?Java Region使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Region類屬於org.altbeacon.beacon包,在下文中一共展示了Region類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createRangingResponse
import org.altbeacon.beacon.Region; //導入依賴的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: onBeaconServiceConnect
import org.altbeacon.beacon.Region; //導入依賴的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();
}
}
示例3: beaconsInRegion
import org.altbeacon.beacon.Region; //導入依賴的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());
}
});
}
});
}
示例4: setActiveRegionList
import org.altbeacon.beacon.Region; //導入依賴的package包/類
private void setActiveRegionList() {
Logger.getInstance().Debug(TAG, "setActiveRegionList");
_previousRegionList = _activeRegionList;
_activeRegionList.clear();
SerializableList<PuckJs> puckJsList = PuckJsListService.getInstance().GetDataList();
Logger.getInstance().Debug(TAG, String.format(Locale.getDefault(), "setActiveRegionList for %d PuckJss", puckJsList.getSize()));
for (int index = 0; index < puckJsList.getSize(); index++) {
PuckJs puckJs = puckJsList.getValue(index);
Region region = new Region(puckJs.GetArea(), puckJs.GetMac());
_activeRegionList.add(region);
}
setMonitorNotifiers();
setRangeNotifiers();
}
示例5: onBeaconServiceConnect
import org.altbeacon.beacon.Region; //導入依賴的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: onCreate
import org.altbeacon.beacon.Region; //導入依賴的package包/類
public void onCreate() {
super.onCreate();
BeaconManager beaconManager = org.altbeacon.beacon.BeaconManager.getInstanceForApplication(this);
// Add parser for iBeacons;
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
Log.d(TAG, "setting up background monitoring for beacons and power saving");
// wake up the app when a beacon is seen
Region region = new Region("backgroundRegion",
null, null, null);
regionBootstrap = new RegionBootstrap(this, region);
// simply constructing this class and holding a reference to it in your custom Application
// class will automatically cause the BeaconLibrary to save battery whenever the application
// is not visible. This reduces bluetooth power usage by about 60%
backgroundPowerSaver = new BackgroundPowerSaver(this);
// If you wish to test beacon detection in the Android Emulator, you can use code like this:
// BeaconManager.setBeaconSimulator(new TimedBeaconSimulator() );
// ((TimedBeaconSimulator) BeaconManager.getBeaconSimulator()).createTimedSimulatedBeacons();
}
示例7: onBeaconServiceConnect
import org.altbeacon.beacon.Region; //導入依賴的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: didEnterRegion
import org.altbeacon.beacon.Region; //導入依賴的package包/類
@Override
public void didEnterRegion(Region region) {
RegionName regName = RegionName.parseString(region.getUniqueId());
if (regName.isApplicationRegion()) {
if (regName.getEventType() == ActionBeacon.EventType.EVENT_NEAR_YOU) {
try {
mBeaconManager.startRangingBeaconsInRegion(region);
} catch (RemoteException e) {
Log.e(Constants.TAG, "Error start ranging region: " + regName, e);
}
}
if (regName.getEventType() == ActionBeacon.EventType.EVENT_ENTERS_REGION) {
Intent intent = new Intent();
intent.setAction(Constants.NOTIFY_BEACON_ENTERS_REGION);
intent.putExtra("REGION", (Parcelable)region);
getApplicationContext().sendOrderedBroadcast(intent, null);
}
}
}
示例9: didExitRegion
import org.altbeacon.beacon.Region; //導入依賴的package包/類
@Override
public void didExitRegion(Region region) {
RegionName regName = RegionName.parseString(region.getUniqueId());
if (regName.isApplicationRegion()) {
if (regName.getEventType() == ActionBeacon.EventType.EVENT_NEAR_YOU) {
try {
mBeaconManager.stopRangingBeaconsInRegion(region);
// set "far" proximity
// mDataManager.updateBeaconDistance(regName.getBeaconId(), 99);
} catch (RemoteException e) {
Log.e(Constants.TAG, "Error stop ranging region: " + regName, e);
}
}
if (regName.getEventType() == ActionBeacon.EventType.EVENT_LEAVES_REGION) {
Intent intent = new Intent();
intent.setAction(Constants.NOTIFY_BEACON_LEAVES_REGION);
intent.putExtra("REGION", (Parcelable) region);
getApplicationContext().sendOrderedBroadcast(intent, null);
}
}
}
示例10: didRangeBeaconsInRegion
import org.altbeacon.beacon.Region; //導入依賴的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: BleManager
import org.altbeacon.beacon.Region; //導入依賴的package包/類
@Inject
public BleManager(@ForApplication Context context, PreferenceManager prefsManager) {
this.context = context;
// the app manifest requires support for BLE, no need to check explicitly
bluetoothManager = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
bluetoothAdapter = bluetoothManager.getAdapter();
preferenceManager = prefsManager;
gattManager = new GattManager(prefsManager, this);
// Beaconing
beaconManager = org.altbeacon.beacon.BeaconManager.getInstanceForApplication(context);
beaconManager.getBeaconParsers().clear();
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));
Timber.d("setting up background monitoring for beacons and power saving");
Identifier id1 = Identifier.parse(ThunderBoardDevice.THUNDER_BOARD_REACT_UUID_STRING);
Region region = new Region("backgroundRegion", id1, null, null);
regionBootstrap = new ThunderBoardBootstrap(context, this, region);
backgroundPowerSaver = new ThunderBoardPowerSaver(context, preferenceManager);
beaconManager.setBackgroundBetweenScanPeriod(ThunderBoardPowerSaver.DELAY_BETWEEN_SCANS_INACTIVE);
}
示例12: didRangeBeaconsInRegion
import org.altbeacon.beacon.Region; //導入依賴的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: disable
import org.altbeacon.beacon.Region; //導入依賴的package包/類
/**
* Used to disable additional bootstrap callbacks after the first is received. Unless this is called,
* your application will be get additional calls as the supplied regions are entered or exited.
*/
public void disable() {
Timber.d("Disabling region bootstrap");
if (disabled) {
return;
}
disabled = true;
try {
for (Region region : regions) {
beaconManager.stopMonitoringBeaconsInRegion(region);
}
} catch (RemoteException e) {
Timber.d("Can't stop bootstrap regions");
}
beaconManager.unbind(beaconConsumer);
}
示例14: didEnterRegion
import org.altbeacon.beacon.Region; //導入依賴的package包/類
@Override
public void didEnterRegion(Region arg0) {
Log.d(TAG, "did enter region.");
if (!haveDetectedBeaconsSinceBoot) {
Log.d(TAG, "auto launching MainActivity");
Intent intent = new Intent(this, BeaconActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
haveDetectedBeaconsSinceBoot = true;
} else {
if (beaconActivity != null) {
// If the Monitoring Activity is visible, we log info about the beacons we have
// seen on its display
beaconActivity.logToDisplay("I see a beacon again" );
} else {
Log.d(TAG, "Sending notification.");
sendNotification();
}
}
}
示例15: onBeaconServiceConnect
import org.altbeacon.beacon.Region; //導入依賴的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) { }
}