本文整理汇总了Java中com.estimote.sdk.BeaconManager.connect方法的典型用法代码示例。如果您正苦于以下问题:Java BeaconManager.connect方法的具体用法?Java BeaconManager.connect怎么用?Java BeaconManager.connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.estimote.sdk.BeaconManager
的用法示例。
在下文中一共展示了BeaconManager.connect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeEstimote
import com.estimote.sdk.BeaconManager; //导入方法依赖的package包/类
/**
* Initialize the Estimote Monitoring to check if a device enters the area of
* a selected Beacon to notify the Harvest time tracking
*/
private void initializeEstimote() {
// Initialize the Beacon manager
mBeaconManager = new BeaconManager(this);
mBeaconManager.setBackgroundScanPeriod(BEACON_SCAN_PERIOD, BEACON_WAIT_PERIOD);
mBeaconManager.setRangingListener(this);
// Connect to the Beacon Service
mBeaconManager.connect(new BeaconManager.ServiceReadyCallback() {
@Override
public void onServiceReady() {
try {
mBeaconManager.startRanging(ALL_ESTIMOTE_BEACONS);
Timber.i("Starting Ranging");
} catch (RemoteException e) {
Timber.d("Error while starting monitoring");
}
}
});
}
示例2: onReceive
import com.estimote.sdk.BeaconManager; //导入方法依赖的package包/类
public void onReceive(Context context, Intent intent) {
beaconManager = new BeaconManager(context);
beaconList = new ArrayList<>(3);
beaconList.add(mBlueberry);
beaconList.add(mIce);
beaconList.add(mMint);
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override
public void onBeaconsDiscovered(Region region, final List<Beacon> rangedBeacons) {
Beacon foundBeacon = null;
for (Beacon rangedBeacon : rangedBeacons) {
for (Beacon supportedBeacon : beaconList) {
if (rangedBeacon.getMajor() == supportedBeacon.getMajor() && rangedBeacon.getMinor() == supportedBeacon.getMinor()) {
foundBeacon = rangedBeacon;
switch (foundBeacon.getName()) {
case BEACON_BLUEBERRY:
Log.i("TRAVELBIRD-BEACON", BEACON_BLUEBERRY + " found!");
break;
case BEACON_ICE:
Log.i("TRAVELBIRD-BEACON", BEACON_ICE + " found!");
break;
case BEACON_MINT:
Log.i("TRAVELBIRD-BEACON", BEACON_MINT + " found!");
break;
}
}
}
}
}
});
beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
@Override
public void onServiceReady() {
Log.i("TRAVELBIRD-BEACON", "CONNECT" + " found!");
}
});
}