本文介绍了如何检测区域进入/退出使用AltBeacon Android的信标库中的多个信标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正与iBeacons和使用AltBeacon库。

I am working with iBeacons and using the AltBeacon library.

beaconManager.getBeaconParsers()。添加(新BeaconParser()。                setBeaconLayout(M:2-3 = 0215,I:4-19,I:20-21,I:22-23,号码:24-24));

beaconManager.getBeaconParsers().add(new BeaconParser(). setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));

我想我的Andr​​oid应用程序,以检测并产生一个事件时,信标进入和退出的知名度。这只是正常罚款与使用方法,使用该库的单一灯塔。公共无效 didEnterRegion (地区区域)和公共无效 didExitRegion (地区区域)

I would like my Android app to detect and generate an event when beacons enter and exit visibility.This works just fine fine with a single beacon using the library using methods.public void didEnterRegion(Region region)andpublic void didExitRegion(Region region)

我的问题是,当多个信标是在同一时间中可见。我试图保持与可见的所有信标阵列。我希望每个信标进入和退出时间生成一个事件。该事件应确定生成该事件被它的唯一标识符指路明灯。我的信标是唯一可识别的使用beacon.getIdentifiers()或(UUID,主要和次要)

My problem is when multiple beacons are visible at the same time.I am trying to maintain an array with all beacons visible.I want to generate an event each time a beacon enters and exits.The event should identify the beacon that generated the event by it's unique Identifier.My beacons are uniquely identifiable using the beacon.getIdentifiers() or ( UUID, Major and Minor)

问题是,在 didExitRegion 方式没有得到执行,直到所有的信标退出该地区。

The problem is that the didExitRegion method does not get executed until all beacons exit the region.

谁能想到一个简单的办法,我用AltBeacon库实现我的目标?

Can anyone think of a simple way for me to achieve my goals using AltBeacon library?

任何建议将是极大的AP preciated。

Any suggestions would be greatly appreciated.

推荐答案

有两个选项:

  1. 设置了不同的区域只匹配每一个信标,指定所有的标识符,并监控每个。你会得到一个不同的入口和出口的回调为每个区域。

  1. Set up a different region to match only each individual beacon, specifying all their identifiers, and monitor for each. You will get a different entry and exit callback for each region.

Region region1 = new Region("myIdentifier1", Identifier.parse("2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6"), Identifier.parse("1"), Identifier.parse("1"));
Region region2 = new Region("myIdentifier2", Identifier.parse("2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6"), Identifier.parse("1"), Identifier.parse("2"));

beaconManager.startMonitoringBeaconsInRegion(region1);
beaconManager.startMonitoringBeaconsInRegion(region2);

  • 启用范围,并把code。在 didRangeBeaconsInRegion 回调跟踪单个信标。您可以使用的java.util.HashMap 跟踪可见的(带时间戳的最晚时间被认为)所有的信标,然后如果你的避风港'牛逼看到,比方说,五秒钟的灯塔,您可以从的HashMap 删除信标,并执行你的出口逻辑的灯塔。

  • Enable ranging, and put code in the didRangeBeaconsInRegion callback to track individual beacons. You can use a java.util.HashMap to keep track of all beacons that are visible (with a timestamp for the latest time each was seen), and then if you haven't seen a beacon in, say, five seconds, you can remove the beacon from the HashMap and execute your exit logic for that beacon.

    选项1是伟大的一小部分,你知道它们的标识符前面的信标。方案2是比较复杂,但对于大量的信标好如果你不知道自己的标识符提前。

    Option 1 is great for a small number of beacons where you know their identifiers up front. Option 2 is more involved, but better for a large number of beacons or if you do not know their identifiers in advance.

    这篇关于如何检测区域进入/退出使用AltBeacon Android的信标库中的多个信标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

  • 08-04 04:18