我正在开发一款适用于Beacons的Android应用程序(感谢Android Beacon Library的使用)。我有一个扩展BootstrapNotifier的应用程序,它调用一个Controller(我的类)方法,该方法创建一个新的RegionBootstrap。应用程序启动时,一切正常,与相应区域相关的信标在进入或离开特定区域时会触发通知。
if($_POST['Hour'] < 10 ){
$concat = "0".$_POST['hour'];
}
这是控制器:
public class BackgroundApplication extends Application implements BootstrapNotifier, RangeNotifier {
...
@Override
public void onCreate() {
this.controller = Controller.getInstance();
mAllBeaconsRegion = new Region("all beacons", null, null, null);
//the following call returns the correct list of regions
this.regionList = this.controller.getRegionList(this);
this.regionList.add(mAllBeaconsRegion);
this.controller.setBootstrapNotifier(this);
this.controller.setRegionBootstrap(this.regionList);
...
}
现在,我可以添加区域,我想立即检测信标何时进入或离开该区域。为此,我想我必须简单地重新调用setRegionBootstrap方法,传递新的Region列表。 相反,除非我重新启动应用程序,否则我没有进入或离开新区域的通知。 知道怎么解决这个问题吗?感谢。
答案 0 :(得分:1)
你应该只构造一次RegionBootstrap。如果要通过添加新区域来更改受监视区域,只需在BeaconManager上直接执行此操作:
beaconManager.startMonitoringBeaconsInRegion(new Region("myMonitoringUniqueId", null, null, null));