本文整理汇总了Java中org.altbeacon.beacon.Identifier类的典型用法代码示例。如果您正苦于以下问题:Java Identifier类的具体用法?Java Identifier怎么用?Java Identifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Identifier类属于org.altbeacon.beacon包,在下文中一共展示了Identifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BleManager
import org.altbeacon.beacon.Identifier; //导入依赖的package包/类
@Inject
public BleManager(@ForApplication Context context, PreferenceManager prefsManager) {
this.context = context;
// the app manifest requires support for BLE, no need to check explicitly
bluetoothManager = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
bluetoothAdapter = bluetoothManager.getAdapter();
preferenceManager = prefsManager;
gattManager = new GattManager(prefsManager, this);
// Beaconing
beaconManager = org.altbeacon.beacon.BeaconManager.getInstanceForApplication(context);
beaconManager.getBeaconParsers().clear();
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"));
Timber.d("setting up background monitoring for beacons and power saving");
Identifier id1 = Identifier.parse(ThunderBoardDevice.THUNDER_BOARD_REACT_UUID_STRING);
Region region = new Region("backgroundRegion", id1, null, null);
regionBootstrap = new ThunderBoardBootstrap(context, this, region);
backgroundPowerSaver = new ThunderBoardPowerSaver(context, preferenceManager);
beaconManager.setBackgroundBetweenScanPeriod(ThunderBoardPowerSaver.DELAY_BETWEEN_SCANS_INACTIVE);
}
示例2: startBeaconService
import org.altbeacon.beacon.Identifier; //导入依赖的package包/类
/**
* Start the XamoomBeaconService with a beacon majorId.
* This will automatically start (background-)monitoring for xamoom beacons
* with the used majorId.
*
* @param majorId MajorId you get from your xamoom system.
*/
public void startBeaconService(@NonNull String majorId) {
Log.i(TAG, "startBeaconService");
if (majorId.equalsIgnoreCase("")) {
throw new IllegalArgumentException("MajorId should not be a number.");
}
mRegion = new Region("test", Identifier.parse("de2b94ae-ed98-11e4-3432-78616d6f6f6d"),
Identifier.parse(majorId), null);
mRegionBootstrap = new RegionBootstrap(this, mRegion);
mBeaconManager = BeaconManager.getInstanceForApplication(mContext);
mBeaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
mBeaconManager.setRangeNotifier(this);
mBeaconManager.bind(this);
}
示例3: onCreate
import org.altbeacon.beacon.Identifier; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
SmartBeaconProvider provider = new SmartBeaconProvider();
/**
* Region represented by all SmartBeacon's beacons
*/
Region region = new Region(REGION_ID, Identifier.parse(provider.getProximityUuid()), null, null);
try {
getBeaconManager().startMonitoringBeaconsInRegion(region);
getBeaconManager().startRangingBeaconsInRegion(region);
} catch (RemoteException e) {
Log.e(TAG, "An error occus on start monitor/range region!");
}
}
示例4: testSerializationBenchmark
import org.altbeacon.beacon.Identifier; //导入依赖的package包/类
@Test
// On MacBookPro 2.5 GHz Core I7, 10000 serialization/deserialiation cycles of RangingData took 22ms
public void testSerializationBenchmark() throws Exception {
Context context = ShadowApplication.getInstance().getApplicationContext();
ArrayList<Identifier> identifiers = new ArrayList<Identifier>();
identifiers.add(Identifier.parse("2f234454-cf6d-4a0f-adf2-f4911ba9ffa6"));
identifiers.add(Identifier.parse("1"));
identifiers.add(Identifier.parse("2"));
Region region = new Region("testRegion", identifiers);
ArrayList<Beacon> beacons = new ArrayList<Beacon>();
Beacon beacon = new Beacon.Builder().setIdentifiers(identifiers).setRssi(-1).setRunningAverageRssi(-2).setTxPower(-50).setBluetoothAddress("01:02:03:04:05:06").build();
for (int i=0; i < 10; i++) {
beacons.add(beacon);
}
RangingData data = new RangingData(beacons, region);
long time1 = System.currentTimeMillis();
for (int i=0; i< 10000; i++) {
Bundle bundle = data.toBundle();
RangingData data2 = RangingData.fromBundle(bundle);
}
long time2 = System.currentTimeMillis();
System.out.println("*** Ranging Data Serialization benchmark: "+(time2-time1));
}
示例5: startSearchForBeacons
import org.altbeacon.beacon.Identifier; //导入依赖的package包/类
private void startSearchForBeacons() {
List<BeaconResult> beacons = beaconPersistence.getBeacons();
List<Region> regions = new ArrayList<>(beacons.size());
for (BeaconResult beacon : beacons) {
String id = beacon.getUuid() + beacon.getMajor() + beacon.getMinor();
try {
Region region = new Region(id,
Identifier.parse(beacon.getUuid()),
Identifier.parse(beacon.getMajor()),
Identifier.parse(beacon.getMinor()));
regions.add(region);
} catch (IllegalArgumentException e) {
String informalName = beacon.getInformalName();
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(getString(R.string.not_able_to_start_monitoring_for_beacon_error_1));
if (informalName != null && !informalName.isEmpty()) {
stringBuilder.append("name: \"").append(informalName).append("\" with ");
}
stringBuilder.append("uuid: \"").append(beacon.getUuid()).append("\" major: \"").append(beacon.getMajor()).append("\" minor: \"").append(beacon.getMinor()).append("\"");
String errorMessage = stringBuilder.toString();
Log.e(TAG, errorMessage, e);
Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show();
}
}
regionBootstrap = new RegionBootstrap(this, regions);
}
示例6: parseRegion
import org.altbeacon.beacon.Identifier; //导入依赖的package包/类
public static Region parseRegion(ActionBeacon actionBeacon) {
if (actionBeacon == null) {
throw new IllegalArgumentException("ActionBeacon object is null");
}
String[] idents = actionBeacon.getBeaconId().split(";");
if (idents == null || idents.length < 3) {
throw new IllegalArgumentException("ActionBeacon has invalid id");
}
List<Identifier> identifiers = new ArrayList<>();
for (int i = 0; i < 3; i++) {
identifiers.add(Identifier.parse(idents[i]));
}
return new Region(RegionName.buildRegionNameId(actionBeacon), identifiers, idents[3]);
}
示例7: PublicTransportBeacon
import org.altbeacon.beacon.Identifier; //导入依赖的package包/类
public PublicTransportBeacon(Identifier id, int type, AbstractBeaconPlace beacon, String simpleName, Integer image){
this.id = id;
this.type = type;
this.simpleName = simpleName;
this.image = image;
this.stats = new BeaconStatistics();
this.inProximity = false;
this.beacon = beacon;
}
示例8: onBeaconServiceConnect
import org.altbeacon.beacon.Identifier; //导入依赖的package包/类
/**
* Method reserved for system use
*/
@Override
public void onBeaconServiceConnect() {
Timber.d("Activating background region monitoring");
beaconManager.setRangeNotifier(rangeNotifier);
try {
Identifier id1 = Identifier.parse("cef797da-2e91-4ea4-a424-f45082ac0682");
beaconManager.startRangingBeaconsInRegion(new Region("ThunderBoardUniqueId", id1, null, null));
} catch (RemoteException e) {
Timber.d("Can't set up bootstrap regions, exception: %s", e.getMessage());
}
}
示例9: addNewRegion
import org.altbeacon.beacon.Identifier; //导入依赖的package包/类
private void addNewRegion(BeaconModel bm) {
Region region = new Region(bm.getUniqueId(), Identifier.parse(bm.getProximityUUID()), Identifier.parse(bm.getProximityMajor().toString()), Identifier.parse(bm.getProximityMinor().toString()));
try {
beaconManager.startMonitoringBeaconsInRegion(region);
beaconManager.startRangingBeaconsInRegion(region);
} catch (RemoteException e) {
ULog.e(TAG, "Cannot start monitor/range region.", e);
}
}
示例10: setupBeaconManager
import org.altbeacon.beacon.Identifier; //导入依赖的package包/类
public void setupBeaconManager(){
if (beaconManager==null && AppPreferences.getBeaconDetectionState()) {
AppPreferences.setBeaconDetected(false);
Log.d(TAG, "Init beacon");
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=0215,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));
beaconManager.setBackgroundScanPeriod(2000l);
beaconManager.setBackgroundBetweenScanPeriod(5000l); // (300000l) every 5 minutes
// wake up the app when any beacon is seen (you can specify specific id filers in the parameters below)
region = new Region(REGION_NAME, Identifier.parse(AppPreferences.getBeaconUuid()), null, null);
regionBootstrap = new RegionBootstrap(this, region);
}
}
示例11: externalClassToModel
import org.altbeacon.beacon.Identifier; //导入依赖的package包/类
@Override public OrchextraRegion externalClassToModel(Region region) {
Identifier uuid = region.getId1();
Identifier major = region.getId2();
Identifier minor = region.getId3();
OrchextraRegion orchextraRegion = new OrchextraRegion(region.getUniqueId(),
(uuid == null)? null : uuid.toString(),
(major == null)? EMPTY_MAJOR : major.toInt(),
(minor == null)? EMPTY_MINOR : major.toInt(),
true);
return orchextraRegion;
}
示例12: getBeaconId
import org.altbeacon.beacon.Identifier; //导入依赖的package包/类
public String getBeaconId(Beacon beacon) {
StringBuilder allIndetifier = new StringBuilder();
List<Identifier> identifierList = beacon.getIdentifiers();
for (Identifier identifier : identifierList) {
allIndetifier.append(identifier.toString() + "-");
}
allIndetifier.deleteCharAt(allIndetifier.length() - 1);
return allIndetifier.toString();
}
示例13: onCreate
import org.altbeacon.beacon.Identifier; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mAllBeaconsRegion = new Region(UNIQUE_ID, Identifier.parse(PROXIMITY_UUID), null, null);
beaconManager = BeaconManager.getInstanceForApplication(this);
beaconManager.getBeaconParsers().add(new BeaconParser()
.setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
beaconManager.bind(this);
}
示例14: startMonitoringForRegion
import org.altbeacon.beacon.Identifier; //导入依赖的package包/类
/**
* Start monitoring a region.
* @param region the region to monitor, expected to be a property dictionary from javascript code.
*/
@Kroll.method
public void startMonitoringForRegion(Object region) {
Log.d(LCAT, "startMonitoringForRegion: " + region);
if (!checkAvailability()) {
Log.d(LCAT, "Bluetooth LE not available or no permissions on this device");
return;
}
try {
HashMap < String, Object > dict = (HashMap < String, Object > ) region;
String identifier = TiConvert.toString(dict, "identifier");
String uuid = TiConvert.toString(dict, "uuid").toLowerCase();
Integer major = (dict.get("major") != null) ? TiConvert.toInt(dict, "major") : null;
Integer minor = (dict.get("minor") != null) ? TiConvert.toInt(dict, "minor") : null;
Identifier id1 = Identifier.parse(uuid);
Identifier id2 = (major == null) ? null : Identifier.fromInt(major);
Identifier id3 = (minor == null) ? null : Identifier.fromInt(minor);
//Region r = new Region(identifier, uuid, major, minor);
Region r = new Region(identifier, id1, id2, id3);
Log.d(LCAT, "Beginning to monitor region " + r);
beaconManager.startMonitoringBeaconsInRegion(r);
} catch (RemoteException ex) {
Log.e(LCAT, "Cannot start monitoring region " + TiConvert.toString(region, "identifier"), ex);
}
}
示例15: startRangingForRegion
import org.altbeacon.beacon.Identifier; //导入依赖的package包/类
/**
* Start ranging a region. You can only range regions into which you have entered.
*
* @param region the region to range, expected to be a property dictionary from javascript code.
*/
@Kroll.method
public void startRangingForRegion(Object region) {
Log.d(LCAT, "startRangingForRegion: " + region);
if (!checkAvailability()) {
Log.d(LCAT, "Bluetooth LE not available or no permissions on this device");
return;
}
try {
HashMap < String, Object > dict = (HashMap < String, Object > ) region;
String identifier = dict.get("identifier").toString(); //TiConvert.toString(dict, "identifier");
String uuid = dict.get("uuid").toString(); //TiConvert.toString(dict, "uuid").toLowerCase();
Integer major = (dict.get("major") != null) ? TiConvert.toInt(dict, "major") : null;
Integer minor = (dict.get("minor") != null) ? TiConvert.toInt(dict, "minor") : null;
Identifier id1 = Identifier.parse(uuid);
Identifier id2 = (major == null) ? null : Identifier.fromInt(major);
Identifier id3 = (minor == null) ? null : Identifier.fromInt(minor);
Region r = new Region(identifier, id1, id2, id3);
Log.d(LCAT, "Beginning to monitor region " + r);
beaconManager.startRangingBeaconsInRegion(r);
} catch (RemoteException ex) {
Log.e(LCAT, "Cannot start ranging region " + TiConvert.toString(region, "identifier"), ex);
}
}