- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用我的设备检测信标设备,从而监控它们并收听范围通知。
我正在使用 this图书馆和图书馆引用应用程序。我设法使用设置信标布局方法收听自定义信标。
第一步。我在应用程序类中设置布局第 2 步。我让 baseactivity 实现 beaconconsume,它执行测距。
当启动范围监控服务/方法时,我们使用“myRangeUniqueId”,但我认为 didexit 和 didenter 方法使用“backgroundId”。为什么会这样?
所以情况是这样的我将信标设备移到几米远,我仍然看到信标通知,但我没有看到信标。即使信标很远,这些消息也会交替变化。
我需要做些什么来防止这种情况发生吗?请帮忙。
代码 fragment 如下:
应用类实现了BootstrapNotifier,代码如下
BeaconManager beaconManager = org.altbeacon.beacon.BeaconManager.getInstanceForApplication(this);
beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout("LAYOUT_HERE"));
Region region = new Region("backgroundRegion",
null, null, null);
regionBootstrap = new RegionBootstrap(this, region);
// simply constructing this class and holding a reference to it in your custom Application
// class will automatically cause the BeaconLibrary to save battery whenever the application
// is not visible. This reduces bluetooth power usage by about 60%
backgroundPowerSaver = new BackgroundPowerSaver(this);
@Override
public void didEnterRegion(Region arg0) {
// In this example, this class sends a notification to the user whenever a Beacon
// matching a Region (defined above) are first seen.
Log.d(TAG, "did enter region.");
if (!haveDetectedBeaconsSinceBoot) {
Log.d(TAG, "auto launching MainActivity");
haveDetectedBeaconsSinceBoot = true;
} else {
// i am not sending out any notification here since there could be multiple beacons and i need to identify any one of them with a specific uuid
}
}
@Override
public void didExitRegion(Region region) {
sendNotification("exited",2);
}
我在 didDetermineStateForRegion
方法中什么都不做,它只是被覆盖了
我有一个 BaseActivity
实现了 BeaconConsumer
private BeaconManager beaconManager = BeaconManager.getInstanceForApplication(this);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
beaconManager.bind(this);
}
@Override
protected void onDestroy() {
super.onDestroy();
beaconManager.unbind(this);
}
@Override
protected void onPause() {
super.onPause();
if(beaconManager.isBound(this))beaconManager.setBackgroundMode(true);
}
@Override
protected void onResume() {
super.onResume();
if (beaconManager.isBound(this)) beaconManager.setBackgroundMode(false);
}
@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."); */
CommonUtilities.sendNotification(BaseActivity.this,"entered",1);
}
}
}
}
}
});
try {
beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId",null, null, null));
} catch (RemoteException e) { }
}
P.S:当我将设备移动到另一个位置时,比如大约 5 米远,我会收到随机通知,告知信标在范围内,然后我立即收到通知,告知信标超出范围。
谢谢
最佳答案
几点:
唯一标识符用作标识区域
的键,因此您可以启动和停止测距和监控。您构建并在系统中注册的每个区域都应该有一个不同的字符串标识符,但该值可以是您不是的任何值,只要它是唯一的即可。
didRangeBeaconsInRegion
回调每秒进行一次,而不仅仅是当移动设备进入信标范围时。
如果当信标在 20 米左右范围内时您收到重复的 didExitRegion
回调,则您的信标可能没有足够频繁地传输。了解信标品牌、型号和传输频率以及您的移动设备型号可能有助于解决此问题。
关于android - 如何识别哪个信标正在退出,当信标超出范围时看到的信标通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29002037/
richfaces如何避免显示丰富 TreeMap 标?我想过滤树,如果一个父亲被填充,他将不会显示,但他的 child 会显示,所以我需要从默认图标更改为无图标。 其中项目代表树节点 最佳答案 组
我的 iPad 屏幕上随机出现多个标签。重要的是它们都完全可见。因此,我使用下面的最后 4 行 Position 标签代码 来尝试确保标签的位置完全在屏幕框架内。然而,即使我在这一行中将 100 替换
我想在我的表格原型(prototype)单元格中声明 4 个标签,以便我可以将 Parse 中的所有数据检索到标签中。正如你在图片中看到的,有 4 个标签,我希望每个标签都有自己的 socket ,但
标 checkout 现又消失?
这个问题在这里已经有了答案: How to prevent buttons from submitting forms (20 个答案) 关闭 4 年前。 我有一个非常简单的程序,它使用 JS 将结
我刚刚编写了一个程序,其中有一个包含 JLabel 组件数组的 JFrame。该数组获取由 for 循环分配的单个标签的位置: for(int i=0; i
我不确定这个问题是否已在本网站的其他地方得到解答,但我很难用语言解释我的问题。这里是:我想做的是按用户选择的标签对crawler_results 中的文章进行排序。因此,文章中出现的标签越多(coun
尽管数据点不重复,但图表上的标 checkout 现了两次。 知道如何解决吗? 这是标签 json: labels: { rotation: -45, formatter: funct
我正在尝试使用 css 在屏幕上呈现 SVG。这是我的文件结构。 Root > Assets > Icon > user-icon.svg。所以,我正在尝试使用 CSS 来添加它: .user-ele
我正在向客户端应用程序发送一条消息 MarketDataSnapshotFullRefresh,但我在 toAdmin 方法中收到“标 checkout 现不止一次”。我得到的原始消息字符串是 8=F
在AndroidManifest.xml中,application标签有: android:label="@string/app_name" 并且 res/values/strings.xml 中的
有人尝试使用react-native-icons吗?我遵循以下步骤: npm install react-native-icons @ latest-保存 在XCode中,在项目导航器中,右键单击Li
在此页面中:enter link description here 没有任何在此表下的 HTML 中: Attribute Value Description ... 但是当我在 Google
我使用 Vaadin 7。我尝试使用以下代码更改组件的图标: Tree tree = new Tree("The Planets and Major Moons"); tree.setIcon(new
我已阅读以下内容 article .我正在尝试使用 BHO 扩展嵌入图标。但是,res://协议(protocol)在 HTTPS 站点中不起作用。在 HTTPS 站点中显示本地镜像是否有解决方法或替
我正在使用以下 HTML 代码: hr { border: none; border-top: 3px double #333; color: #333; overflow: visi
我无法弄清楚 背后的复杂逻辑元素实际上被放置。我想要一个有两行的表格。我想要每一行的标签,然后是一个输入框。我想要响应行为,当视口(viewport)变窄时,标 checkout 现在输入的正上方。
我有一个严重的问题 :( 我正在制作一个个人资料页面,我的 DIV 总是可点击的(这不应该发生),当我在 chrome 上检查它的元素时,它显示了所有 DIVS 上的一堆......我做到了不在这里写
我有一个以前没有遇到过的问题,我希望能得到一些相关信息。我有一个导航栏显示在网页的顶部,由于某种原因,当代码运行时,浏览器添加了一些 a>/a> 标签,这导致我的链接有一些...处置本身。我希望找出如
我正在使用 Fix 4.3 并遇到两个问题,如果我能解决一个问题,那么应该会消除第二个问题。 但是...我正在使用 QuickFIX 示例文件作为开始我的项目的方式,我能够连接到目标机器并获取市场数据
标 checkout 现在图片的底部吗?
我对这个 html/css 完全陌生,我正在尝试将带有背景的文本作为图像 float 。是的,我这样做了,但问题是文本 float 在图像的顶部。如果使用 margin-top 进行调整图片,它只是简
我是一名优秀的程序员,十分优秀!