public org.altbeacon.beacon.Region startMonitoringRegion(Region regionToStartMonitoring) { org.altbeacon.beacon.Region newMonitoredRegion = getAltBeaconRegionFromWMRegion(regionToStartMonitoring); try { mBeaconManager.startMonitoringBeaconsInRegion(newMonitoredRegion); } catch (RemoteException e) { Log.println(Log.ERROR, "startMonitoringRegion", e.getMessage()); } return newMonitoredRegion; }
/** * Called when the beacon service is running and ready to accept your commands through the * BeaconManager 开始查找beacon */ @Override public void onBeaconServiceConnect() { /** * Tells the BeaconService to start looking for beacons that match the passed Region * object. Note that the Region's unique identifier must be retained保存 to later call the * stopMonitoringBeaconsInRegion method. */ try { // 通知BeaconService,开始监控特定区域的Beacons,一旦检测到beacons,执行MonitorNotifier接口中的回调(进入,离开,临界) mBeaconManager.startMonitoringBeaconsInRegion(ALL_VOLIAM_BEACONS_REGION); } catch (RemoteException e) { LogManager.d(TAG, "RemoteException:" + e.toString()); } }