Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
“我怎么能?”;刷新“;my RegionBootstrap(Android Beacon库)?_Android_Ibeacon_Android Library_Region_Android Ibeacon - Fatal编程技术网

“我怎么能?”;刷新“;my RegionBootstrap(Android Beacon库)?

“我怎么能?”;刷新“;my RegionBootstrap(Android Beacon库)?,android,ibeacon,android-library,region,android-ibeacon,Android,Ibeacon,Android Library,Region,Android Ibeacon,我正在开发一个Android应用程序,它可以与Beacons一起工作(多亏了Android Beacon库的使用)。我有一个扩展BootstrapNotifier的应用程序,它调用一个控制器(我的类)方法来创建一个新的RegionBootstrap。当应用程序启动时,一切正常,并且与相应区域相关的信标在进入或离开特定区域时触发通知 public class BackgroundApplication extends Application implements BootstrapNotifier

我正在开发一个Android应用程序,它可以与Beacons一起工作(多亏了Android Beacon库的使用)。我有一个扩展BootstrapNotifier的应用程序,它调用一个控制器(我的类)方法来创建一个新的RegionBootstrap。当应用程序启动时,一切正常,并且与相应区域相关的信标在进入或离开特定区域时触发通知

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);
    ...

}
这是控制器:

public class Controller {
...
    public void setRegionBootstrap(ArrayList<Region> regionList){

        this.regionBootstrap = new RegionBootstrap(this.bootstrapNotifier, regionList);

    }

    public void setBootstrapNotifier (BootstrapNotifier bn){
        this.bootstrapNotifier = bn;
    }
}
公共类控制器{
...
公共无效setRegionBootstrap(ArrayList regionList){
this.regionBootstrap=newregionbootstrap(this.bootstrapNotifier,regionList);
}
公共无效收货通知(BootstrapNotifier bn){
this.bootstrapNotifier=bn;
}
}
现在,我提供了添加区域的可能性,我想立即检测信标何时进入或离开该区域。为此,我认为我必须简单地重新调用setRegionBootstrap方法,传递新的区域列表。 相反,除非重新启动应用程序,否则我不会收到进入或离开新区域的通知。
你知道我该怎么解决这个问题吗?谢谢。

您应该只构建一次RegionBootstrap。如果要通过添加新区域来更改受监控区域,只需在BeaconManager上直接执行以下操作:

beaconManager.startMonitoringBeaconsInRegion(new Region("myMonitoringUniqueId", null, null, null));

非常感谢大卫,它成功了。感谢您为Android Beacon库所做的大量工作,这真是太棒了。希望这个应用程序能成为我大学学士学位的项目,如果没有你,这是不可能的。