无法获取估计信标的主要和次要值以持久保存到数据库中
Unable to get the major and minor values of an estimote beacon to persist into a database
我正在尝试使用 ibeacons 构建企业应用程序。我购买了 Estimote Beacons Kit 并尝试构建一个 Android 应用程序来获取每个信标的 ID,这样我就可以将该 ID 保存到数据库中并为该应用程序编写我自己的业务逻辑。
谁能帮我测一下信标。我完成了监控信标并相应地发送通知。现在我只想对 Beacon 进行测距并获取 ID。请帮助获取信标主要值和次要值的代码,以便我可以从那里启动我的应用程序。
您可以使用 Estimote Android SDK for that. See quickstart 信标测距:
private BeaconManager beaconManager = new BeaconManager(context);
// Should be invoked in #onCreate.
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override public void onBeaconsDiscovered(Region region, List<Beacon> beacons) {
Log.d(TAG, "Ranged beacons: " + beacons);
}
});
// Should be invoked in #onStart.
beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
@Override public void onServiceReady() {
try {
beaconManager.startRanging(ALL_ESTIMOTE_BEACONS);
} catch (RemoteException e) {
Log.e(TAG, "Cannot start ranging", e);
}
}
});
// Should be invoked in #onStop.
try {
beaconManager.stopRanging(ALL_ESTIMOTE_BEACONS);
} catch (RemoteException e) {
Log.e(TAG, "Cannot stop but it does not matter now", e);
}
// When no longer needed. Should be invoked in #onDestroy.
beaconManager.disconnect();
我正在尝试使用 ibeacons 构建企业应用程序。我购买了 Estimote Beacons Kit 并尝试构建一个 Android 应用程序来获取每个信标的 ID,这样我就可以将该 ID 保存到数据库中并为该应用程序编写我自己的业务逻辑。
谁能帮我测一下信标。我完成了监控信标并相应地发送通知。现在我只想对 Beacon 进行测距并获取 ID。请帮助获取信标主要值和次要值的代码,以便我可以从那里启动我的应用程序。
您可以使用 Estimote Android SDK for that. See quickstart 信标测距:
private BeaconManager beaconManager = new BeaconManager(context);
// Should be invoked in #onCreate.
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override public void onBeaconsDiscovered(Region region, List<Beacon> beacons) {
Log.d(TAG, "Ranged beacons: " + beacons);
}
});
// Should be invoked in #onStart.
beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
@Override public void onServiceReady() {
try {
beaconManager.startRanging(ALL_ESTIMOTE_BEACONS);
} catch (RemoteException e) {
Log.e(TAG, "Cannot start ranging", e);
}
}
});
// Should be invoked in #onStop.
try {
beaconManager.stopRanging(ALL_ESTIMOTE_BEACONS);
} catch (RemoteException e) {
Log.e(TAG, "Cannot stop but it does not matter now", e);
}
// When no longer needed. Should be invoked in #onDestroy.
beaconManager.disconnect();