本文介绍了正确的布局来检测KONTAKT灯塔在Android与AltBeacon的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检测KONTAKT信标具有以下BeaconLayout:

I'm trying to detect a Kontakt Beacon with the following BeaconLayout:

setBeaconLayout("m:8-9=0215,i:10-13,i:14-15,i:16-17,i:18-25"));

但我似乎没有被正确地这样做。广告数据包的结构是这样的:

but I don't seem to be doing it correctly. The advertising packet structure is like this:

在此先感谢。

推荐答案

由于@davidgyoung的意见,我终于发现我的KONTAKT标有以下code:

Thanks to @davidgyoung comments, I finally could detect my Kontakt beacon with the following code:

public class MainActivity extends Activity implements BeaconConsumer {

protected static final String TAG = "RangingActivity";
BeaconManager beaconManager = BeaconManager.getInstanceForApplication(this);

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);        
    beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));
    beaconManager.bind(this);    
}

@Override
public void onBeaconServiceConnect() {
      beaconManager.setRangeNotifier(new RangeNotifier() {
            @Override 
            public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
                if (beacons.size() > 0) {
                    Log.d(TAG, "The first beacon I see is about "+beacons.iterator().next().getDistance()+" meters away.");     
                }
            }
            });

            try {
                beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
            } catch (RemoteException e) {   }
}

请注意,我使用的是2.2版本KONTAKT灯塔,这是一个不同的版本,从上面贴的布局。

Please note that I'm using a 2.2 version Kontakt beacon, which is a different version from the layout posted above.

这篇关于正确的布局来检测KONTAKT灯塔在Android与AltBeacon的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 03:08