【发布时间】:2016-03-08 11:53:08
【问题描述】:
我正在使用 PiBeacon 作为信标设备开发 Android 信标应用程序。
我已将 Respberry Pi 设置为 adfruit website 上给出的信标设备。
我可以看到 PiBeacon 正在使用 Play 商店中提供的其他 BLE 扫描仪应用程序进行传输。
我已经下载了 Altbeacon 并根据Altbeacon Sample 上的给定指南配置了我的 Android Studio 项目,但该应用程序没有显示 ble 设备。谁能帮助我我做错了什么?
以下是我用于扫描 PiBeacon 的代码。
public class MonitoringActivity extends Activity implements BeaconConsumer {
protected static final String TAG = "MonitoringActivity";
private BeaconManager beaconManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ranging);
beaconManager = BeaconManager.getInstanceForApplication(this);
// To detect proprietary beacons, you must add a line like below corresponding to your beacon
// type. Do a web search for "setBeaconLayout" to get the proper expression.
// beaconManager.getBeaconParsers().add(new BeaconParser().
// setBeaconLayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));
beaconManager.bind(this);
}
@Override
protected void onDestroy() {
super.onDestroy();
beaconManager.unbind(this);
}
@Override
public void onBeaconServiceConnect() {
beaconManager.setMonitorNotifier(new MonitorNotifier() {
@Override
public void didEnterRegion(Region region) {
Log.i(TAG, "I just saw an beacon for the first time!");
}
@Override
public void didExitRegion(Region region) {
Log.i(TAG, "I no longer see an beacon");
}
@Override
public void didDetermineStateForRegion(int state, Region region) {
Log.i(TAG, "I have just switched from seeing/not seeing beacons: "+state);
}
});
try {
beaconManager.startMonitoringBeaconsInRegion(new Region("myMonitoringUniqueId", null, null, null));
} catch (RemoteException e) { }
}
}
【问题讨论】:
标签: android raspberry-pi ibeacon-android altbeacon android-ibeacon