当前位置: 首页>>代码示例>>Java>>正文


Java Identifier类代码示例

本文整理汇总了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);
}
 
开发者ID:SiliconLabs,项目名称:thunderboard-android,代码行数:25,代码来源:BleManager.java

示例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);
}
 
开发者ID:xamoom,项目名称:xamoom-pingeborg-android,代码行数:26,代码来源:XamoomBeaconService.java

示例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!");
    }
}
 
开发者ID:ludriv,项目名称:smooth-beacon,代码行数:19,代码来源:SampleApplication.java

示例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));
}
 
开发者ID:AltBeacon,项目名称:android-beacon-library,代码行数:24,代码来源:RangingDataTest.java

示例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);
}
 
开发者ID:bjaanes,项目名称:BeaconMqtt,代码行数:31,代码来源:BeaconApplication.java

示例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]);
}
 
开发者ID:mobillium,项目名称:omnicrow-android,代码行数:16,代码来源:ActionRegion.java

示例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;
}
 
开发者ID:JonathanVidmar,项目名称:BLEPublicTransport,代码行数:10,代码来源:PublicTransportBeacon.java

示例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());
    }
}
 
开发者ID:SiliconLabs,项目名称:thunderboard-android,代码行数:16,代码来源:ThunderBoardBootstrap.java

示例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);
    }
}
 
开发者ID:upnext,项目名称:BeaconControl_Android_SDK,代码行数:10,代码来源:ClientsManager.java

示例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);
    }
}
 
开发者ID:letolab,项目名称:LETO-Toggl_Android,代码行数:16,代码来源:CoreApplication.java

示例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;
  }
 
开发者ID:Orchextra,项目名称:orchextra-android-sdk,代码行数:15,代码来源:BeaconRegionAndroidMapper.java

示例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();
}
 
开发者ID:swandroid,项目名称:swan-sense-studio,代码行数:11,代码来源:BeaconSingleton.java

示例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);
}
 
开发者ID:gazzumatteo,项目名称:AndroidBeaconWearSample,代码行数:12,代码来源:MainActivity.java

示例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);
	}
}
 
开发者ID:dwk5123,项目名称:android-altbeacon-module,代码行数:34,代码来源:AndroidAltbeaconModuleModule.java

示例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);
	}
}
 
开发者ID:dwk5123,项目名称:android-altbeacon-module,代码行数:33,代码来源:AndroidAltbeaconModuleModule.java


注:本文中的org.altbeacon.beacon.Identifier类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。