本文整理汇总了Java中org.altbeacon.beacon.RangeNotifier类的典型用法代码示例。如果您正苦于以下问题:Java RangeNotifier类的具体用法?Java RangeNotifier怎么用?Java RangeNotifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RangeNotifier类属于org.altbeacon.beacon包,在下文中一共展示了RangeNotifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBeaconServiceConnect
import org.altbeacon.beacon.RangeNotifier; //导入依赖的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();
}
}
示例2: beaconsInRegion
import org.altbeacon.beacon.RangeNotifier; //导入依赖的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());
}
});
}
});
}
示例3: onBeaconServiceConnect
import org.altbeacon.beacon.RangeNotifier; //导入依赖的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();
}
}
示例4: onBeaconServiceConnect
import org.altbeacon.beacon.RangeNotifier; //导入依赖的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) { }
}
示例5: onBeaconServiceConnect
import org.altbeacon.beacon.RangeNotifier; //导入依赖的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) { }
}
示例6: onBeaconServiceConnect
import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
@Override
public void onBeaconServiceConnect() {
beaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
final Collection<Beacon> beaconsfinal = new ArrayList<Beacon>(beacons);
runOnUiThread(new Runnable() {
@Override
public void run() {
toolbar.setSubtitle(String.format("%d beacons discovered.", beaconsfinal.size()));
adapter.replaceWith(beaconsfinal);
}
});
}
});
try {
beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
} catch (RemoteException e) {
Log.d(TAG, "RemoteException");
}
}
示例7: onBeaconServiceConnect
import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
@Override
public void onBeaconServiceConnect() {
mBeaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
mBeacons.clear();
if (beacons.size() > 0) {
mBeacons.addAll(beacons);
}
if (getActivity() != null) getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
mAdapter.notifyDataSetChanged();
}
});
}
});
try {
mBeaconManager.startRangingBeaconsInRegion(new Region(UNIQUE_RANGING_ID, null, null, null));
} catch (RemoteException e) {
e.printStackTrace();
}
}
示例8: onBeaconServiceConnect
import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
@Override
public void onBeaconServiceConnect() {
beaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
beacons_l.clear();
beacons_l.addAll(beacons);
logToDisplay(beacons_l);
if (beacons.size() > 0) {
ticks ++;
speech(beacons_l);
}
}
});
try {
beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
} catch (RemoteException e) { }
}
示例9: onBeaconServiceConnect
import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
@Override
public void onBeaconServiceConnect() {
beaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
if (beacons.size() > 0) {
updateText(beacons.iterator().next().getDistance());
}
}
});
try {
beaconManager.startRangingBeaconsInRegion(new Region("here", null, null, null));
} catch (RemoteException e) {
e.printStackTrace();
}
}
示例10: startFullScan
import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
public void startFullScan() {
assertServiceReady();
if (beaconManager.getRangedRegions().contains(FULL_SCAN_REGION)) return;
for (Region r : beaconManager.getRangedRegions()) {
stopRanging(r);
}
beaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> iBeacons, Region region) {
postOnMainThread(new FullScanCompleteEvent(iBeacons));
}
});
try {
beaconManager.startRangingBeaconsInRegion(FULL_SCAN_REGION);
Log.i(TAG, "Full scan started");
} catch (RemoteException e) {
Log.e(TAG, "Could not start full scan", e);
}
}
示例11: onBeaconServiceConnect
import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
@Override
public void onBeaconServiceConnect() {
beaconManager.addRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(final Collection<Beacon> beacons, Region region) {
Log.d("beacons", beacons.size() + "");
if (beacons.size() > 0) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Iterator<Beacon> beaconIterator = beacons.iterator();
double distance = 1000f;
while (beaconIterator.hasNext()) {
Beacon beacon = beaconIterator.next();
Log.i("beacons", "The first beacon I see is about " + beacon.getBluetoothAddress() + " meters away.");
if (beacon.getBluetoothAddress().equals("C9:FE:F5:0D:BB:3A"))
distance = beacon.getDistance();
}
mMainTv.setText("Min distance: " + distance);
}
});
}
}
});
try {
beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
} catch (RemoteException e) {
}
}
示例12: ThunderBoardBootstrap
import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
public ThunderBoardBootstrap(Context context, RangeNotifier rangeNotifier, Region region) {
this.context = context;
this.rangeNotifier = rangeNotifier;
beaconManager = BeaconManager.getInstanceForApplication(context);
regions = new ArrayList<>();
regions.add(region);
beaconConsumer = new InternalBeaconConsumer();
beaconManager.bind(beaconConsumer);
Timber.d("Waiting for BeaconService connection");
}
示例13: onBeaconServiceConnect
import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
@Override
public void onBeaconServiceConnect() {
Log.d(TAG, "On beacon connect+++++++++++++++++");
beaconManager.setBackgroundMode(false);
beaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
Log.d(TAG, "++ " + beacons.size());
if (beacons.isEmpty())
return;
HashMap<String, Beacon> beaconData = new HashMap<String, Beacon>();
for (Beacon beacon : beacons) {
beaconData.put(getBeaconId(beacon), beacon);
}
long time = System.currentTimeMillis();
try {
lock.lock();
for (AbstractBeaconSensor sensor : sensors) {
sensor.setData(beaconData, time);
}
} finally {
lock.unlock();
}
}
});
try {
beaconManager.startRangingBeaconsInRegion(myRegion);
} catch (RemoteException e) {
Log.d(TAG, "Got exception" + e.getMessage());
}
}
示例14: onBeaconServiceConnect
import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
@Override
public void onBeaconServiceConnect() {
beaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
if (beacons.size() > 0) {
final ArrayList<BeaconModel> list = new ArrayList<BeaconModel>();
Iterator<Beacon> it = beacons.iterator();
while (it.hasNext()) {
Beacon beacon = it.next();
BeaconModel model = new BeaconModel();
if (beacon.getServiceUuid() == 0xfeaa)
{
// This is Eddystone, which uses a service Uuid of 0xfeaa
Identifier eddystoneNamespaceId = beacon.getId1();
Identifier eddystoneInstanceId = beacon.getId2();
}
else
{
}
model.setBeaconName("Rssi: " + beacon.getRssi() + " Power: " + beacon.getTxPower());
model.setDistance("Dist: " + beacon.getDistance());
list.add(model);
}
runOnUiThread(new Runnable() {
@Override
public void run() {
CustomBeaconAdapter adapter = new CustomBeaconAdapter(list, MainActivity.this);
beaconList.setAdapter(adapter);
}
});
}
}
});
try {
beaconManager.startRangingBeaconsInRegion(new Region("myMonitoringUniqueId", null, null, null));
} catch (RemoteException e) {
e.printStackTrace();
}
}
示例15: setupBeaconManager
import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
private void setupBeaconManager() {
mBeaconManager = BeaconManager.getInstanceForApplication(mFindMyTagView.get().getContext());
mBeaconManager.getBeaconParsers().clear();
mBeaconManager.getBeaconParsers().add(
new BeaconParser().setBeaconLayout(MY_BEACON_LAYOUT)
);
// mBeaconManager.setMonitorNotifier(new MonitorNotifier() {
// @Override
// public void didEnterRegion(Region region) {
// Log.d(TAG, "didEnterRegion: " + region.toString());
// mFindMyTagView.get().onBeaconEnter(region.toString());
// }
//
// @Override
// public void didExitRegion(Region region) {
// Log.d(TAG, "didExitRegion: " + region.toString());
// mFindMyTagView.get().onBeaconExit(region.toString());
// }
//
// @Override
// public void didDetermineStateForRegion(int state, Region region) {
// Log.d(TAG, "didDetermineStateForRegion: " + region.toString() + " state: " + state);
// mFindMyTagView.get().onBeaconState(state, region.toString());
// }
// });
mBeaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
if (mFindMyTagView.get() != null && beacons.size() > 0) {
Beacon beacon = beacons.iterator().next();
Log.i(TAG, "UUID: " + beacon.getBluetoothAddress() + " beacon: " + beacon.getBluetoothName() + " distance: " + beacon.getDistance() + " data: " + beacon.getDataFields());
String uid = beacon.getBluetoothAddress();
mFindMyTagView.get().onBeaconEnter(beacon);
if (TextUtils.isEmpty(mFliterUid) || !uid.equals(mFliterUid))
return;
mFindMyTagView.get().onBeaconDistance(uid, beacon.getBluetoothName(), beacon.getDistance(), beacon.getDataFields());
}
}
});
mBeaconManager.bind(this);
}