當前位置: 首頁>>代碼示例>>Java>>正文


Java Region類代碼示例

本文整理匯總了Java中org.altbeacon.beacon.Region的典型用法代碼示例。如果您正苦於以下問題:Java Region類的具體用法?Java Region怎麽用?Java Region使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Region類屬於org.altbeacon.beacon包,在下文中一共展示了Region類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createRangingResponse

import org.altbeacon.beacon.Region; //導入依賴的package包/類
private WritableMap createRangingResponse(Collection<Beacon> beacons, Region region) {
    WritableMap map = new WritableNativeMap();
    map.putString("identifier", region.getUniqueId());
    map.putString("uuid", region.getId1() != null ? region.getId1().toString() : "");
    WritableArray a = new WritableNativeArray();
    for (Beacon beacon : beacons) {
        WritableMap b = new WritableNativeMap();
        b.putString("uuid", beacon.getId1().toString());
        b.putInt("major", beacon.getId2().toInt());
        b.putInt("minor", beacon.getId3().toInt());
        b.putInt("rssi", beacon.getRssi());
        b.putDouble("distance", beacon.getDistance());
        b.putString("proximity", getProximity(beacon.getDistance()));
        a.pushMap(b);
    }
    map.putArray("beacons", a);
    return map;
}
 
開發者ID:MacKentoch,項目名稱:react-native-ibeacons,代碼行數:19,代碼來源:BeaconsAndroidModule.java

示例2: onBeaconServiceConnect

import org.altbeacon.beacon.Region; //導入依賴的package包/類
@Override
public void onBeaconServiceConnect() {
    mBeaconManager.setRangeNotifier(new RangeNotifier() {
        @Override
        public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
            if (beacons.size() > 0) {
                mBeacon = beacons.iterator().next();
            }

            if (getActivity() != null) getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    loadBeacon();
                }
            });
        }
    });

    try {
        mBeaconManager.startRangingBeaconsInRegion(new Region(UNIQUE_RANGING_ID, mBeacon.getId1(), mBeacon.getId2(), mBeacon.getId3()));
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}
 
開發者ID:menvia,項目名稱:farol-android-sample,代碼行數:25,代碼來源:BeaconFragment.java

示例3: beaconsInRegion

import org.altbeacon.beacon.Region; //導入依賴的package包/類
public Observable<RxBeaconRange> beaconsInRegion() {
    return startup()
            .flatMap(new Function<Boolean, ObservableSource<RxBeaconRange>>() {
                @Override
                public ObservableSource<RxBeaconRange> apply(@NonNull Boolean aBoolean) throws Exception {
                    return Observable.create(new ObservableOnSubscribe<RxBeaconRange>() {
                        @Override
                        public void subscribe(@NonNull final ObservableEmitter<RxBeaconRange> objectObservableEmitter) throws Exception {
                            beaconManager.addRangeNotifier(new RangeNotifier() {
                                @Override
                                public void didRangeBeaconsInRegion(Collection<Beacon> collection, Region region) {
                                    objectObservableEmitter.onNext(new RxBeaconRange(collection, region));
                                }
                            });
                            beaconManager.startRangingBeaconsInRegion(getRegion());
                        }
                    });
                }
            });
}
 
開發者ID:florent37,項目名稱:RxBeacon,代碼行數:21,代碼來源:RxBeacon.java

示例4: setActiveRegionList

import org.altbeacon.beacon.Region; //導入依賴的package包/類
private void setActiveRegionList() {
    Logger.getInstance().Debug(TAG, "setActiveRegionList");

    _previousRegionList = _activeRegionList;
    _activeRegionList.clear();

    SerializableList<PuckJs> puckJsList = PuckJsListService.getInstance().GetDataList();
    Logger.getInstance().Debug(TAG, String.format(Locale.getDefault(), "setActiveRegionList for %d PuckJss", puckJsList.getSize()));

    for (int index = 0; index < puckJsList.getSize(); index++) {
        PuckJs puckJs = puckJsList.getValue(index);
        Region region = new Region(puckJs.GetArea(), puckJs.GetMac());
        _activeRegionList.add(region);
    }

    setMonitorNotifiers();
    setRangeNotifiers();
}
 
開發者ID:GuepardoApps,項目名稱:LucaHome-AndroidApplication,代碼行數:19,代碼來源:PositioningService.java

示例5: onBeaconServiceConnect

import org.altbeacon.beacon.Region; //導入依賴的package包/類
@Override
public void onBeaconServiceConnect() {
    beaconManager.setRangeNotifier(new RangeNotifier() {
        @Override
        public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
            if (beacons.size() > 0) {
                Log.i(TAG, "The first beacon I see is about " + beacons.iterator().next().getDistance() + " meters away.");
            }
        }
    });

    try {
        beaconManager.startRangingBeaconsInRegion(new Region("com.beacon.demo", null, null, null));
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}
 
開發者ID:sahir,項目名稱:eddystone-beacon,代碼行數:18,代碼來源:BeaconApplication.java

示例6: onCreate

import org.altbeacon.beacon.Region; //導入依賴的package包/類
public void onCreate() {
    super.onCreate();
    BeaconManager beaconManager = org.altbeacon.beacon.BeaconManager.getInstanceForApplication(this);

    // Add parser for iBeacons;
    beaconManager.getBeaconParsers().add(new BeaconParser().
            setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));

    Log.d(TAG, "setting up background monitoring for beacons and power saving");
    // wake up the app when a beacon is seen
    Region region = new Region("backgroundRegion",
            null, null, null);
    regionBootstrap = new RegionBootstrap(this, region);

    // simply constructing this class and holding a reference to it in your custom Application
    // class will automatically cause the BeaconLibrary to save battery whenever the application
    // is not visible.  This reduces bluetooth power usage by about 60%
    backgroundPowerSaver = new BackgroundPowerSaver(this);

    // If you wish to test beacon detection in the Android Emulator, you can use code like this:
    // BeaconManager.setBeaconSimulator(new TimedBeaconSimulator() );
    // ((TimedBeaconSimulator) BeaconManager.getBeaconSimulator()).createTimedSimulatedBeacons();
}
 
開發者ID:VNGIoTLab,項目名稱:vbluno_android_ibeacon,代碼行數:24,代碼來源:BeaconReferenceApplication.java

示例7: onBeaconServiceConnect

import org.altbeacon.beacon.Region; //導入依賴的package包/類
@Override
public void onBeaconServiceConnect() {
    beaconManager.setRangeNotifier(new RangeNotifier() {
       @Override
       public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
          if (beacons.size() > 0) {
              arrListBeacon.clear();
              arrListBeacon.addAll(beacons);
              showListBeacon();
          }
       }

    });

    try {
        beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
    } catch (RemoteException e) {   }
}
 
開發者ID:VNGIoTLab,項目名稱:vbluno_android_ibeacon,代碼行數:19,代碼來源:RangingActivity.java

示例8: didEnterRegion

import org.altbeacon.beacon.Region; //導入依賴的package包/類
@Override
public void didEnterRegion(Region region) {
    RegionName regName = RegionName.parseString(region.getUniqueId());

    if (regName.isApplicationRegion()) {
        if (regName.getEventType() == ActionBeacon.EventType.EVENT_NEAR_YOU) {
            try {
                mBeaconManager.startRangingBeaconsInRegion(region);
            } catch (RemoteException e) {
                Log.e(Constants.TAG, "Error start ranging region: " + regName, e);
            }
        }
        if (regName.getEventType() == ActionBeacon.EventType.EVENT_ENTERS_REGION) {
            Intent intent = new Intent();
            intent.setAction(Constants.NOTIFY_BEACON_ENTERS_REGION);
            intent.putExtra("REGION", (Parcelable)region);
            getApplicationContext().sendOrderedBroadcast(intent, null);
        }
    }
}
 
開發者ID:mobillium,項目名稱:omnicrow-android,代碼行數:21,代碼來源:ApplicationClass.java

示例9: didExitRegion

import org.altbeacon.beacon.Region; //導入依賴的package包/類
@Override
    public void didExitRegion(Region region) {

        RegionName regName = RegionName.parseString(region.getUniqueId());

        if (regName.isApplicationRegion()) {
            if (regName.getEventType() == ActionBeacon.EventType.EVENT_NEAR_YOU) {
                try {
                    mBeaconManager.stopRangingBeaconsInRegion(region);
                    // set "far" proximity
//                    mDataManager.updateBeaconDistance(regName.getBeaconId(), 99);
                } catch (RemoteException e) {
                    Log.e(Constants.TAG, "Error stop ranging region: " + regName, e);
                }
            }
            if (regName.getEventType() == ActionBeacon.EventType.EVENT_LEAVES_REGION) {
                Intent intent = new Intent();
                intent.setAction(Constants.NOTIFY_BEACON_LEAVES_REGION);
                intent.putExtra("REGION", (Parcelable) region);
                getApplicationContext().sendOrderedBroadcast(intent, null);
            }
        }
    }
 
開發者ID:mobillium,項目名稱:omnicrow-android,代碼行數:24,代碼來源:ApplicationClass.java

示例10: didRangeBeaconsInRegion

import org.altbeacon.beacon.Region; //導入依賴的package包/類
@Override
    public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
        if (beacons != null && beacons.size() > 0 && region != null) {
            RegionName regName = RegionName.parseString(region.getUniqueId());
            if (regName.isApplicationRegion()) {
                if (regName.getEventType() == ActionBeacon.EventType.EVENT_NEAR_YOU) {
                    Iterator<Beacon> iterator = beacons.iterator();
                    while (iterator.hasNext()) {
                        Beacon beacon = iterator.next();
//                        TrackedBeacon tracked = mDataManager.getBeacon(regName.getBeaconId());
//                        mDataManager.updateBeaconDistance(regName.getBeaconId(), beacon.getDistance());
//                        if (tracked != null && BeaconUtil.isInProximity(IManagedBeacon.ProximityType.FAR, tracked.getDistance())) {
//                            if (BeaconUtil.isInProximity(IManagedBeacon.ProximityType.NEAR, beacon.getDistance())
//                                    || BeaconUtil.isInProximity(IManagedBeacon.ProximityType.IMMEDIATE, beacon.getDistance())) {
//
//                                Intent intent = new Intent();
//                                intent.setAction(Constants.NOTIFY_BEACON_NEAR_YOU_REGION);
//                                intent.putExtra("REGION", (Parcelable)region);
//                                getApplicationContext().sendOrderedBroadcast(intent, null);
//                            }
//                        }
                    }
                }
            }
        }
    }
 
開發者ID:mobillium,項目名稱:omnicrow-android,代碼行數:27,代碼來源:ApplicationClass.java

示例11: BleManager

import org.altbeacon.beacon.Region; //導入依賴的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

示例12: didRangeBeaconsInRegion

import org.altbeacon.beacon.Region; //導入依賴的package包/類
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {

    Iterator<Beacon> iterator = beacons.iterator();

    while (iterator.hasNext()) {

        //EditText editText = (EditText)RangingActivity.this.findViewById(R.id.rangingText);
        Beacon beacon = iterator.next();
        Timber.d("beacon %s  is about: %f meters away.", beacon.toString(), beacon.getDistance());

        deviceFound(beacon);
        if (backgroundPowerSaver.isScannerActivityResumed()) {
            scanner.onNext(devices);
        } else if (SystemClock.elapsedRealtime() - backgroundPowerSaver.getScannerActivityDestroyedTimestamp() >
                ThunderBoardPowerSaver.DELAY_NOTIFICATIONS_TIME_THRESHOLD
                && backgroundPowerSaver.isApplicationBackgrounded()) {
            Timber.d("Sending notification.");
            sendNotification(beacon);
        }
    }
}
 
開發者ID:SiliconLabs,項目名稱:thunderboard-android,代碼行數:23,代碼來源:BleManager.java

示例13: disable

import org.altbeacon.beacon.Region; //導入依賴的package包/類
/**
 * Used to disable additional bootstrap callbacks after the first is received.  Unless this is called,
 * your application will be get additional calls as the supplied regions are entered or exited.
 */
public void disable() {
    Timber.d("Disabling region bootstrap");
    if (disabled) {
        return;
    }
    disabled = true;
    try {
        for (Region region : regions) {
            beaconManager.stopMonitoringBeaconsInRegion(region);
        }
    } catch (RemoteException e) {
        Timber.d("Can't stop bootstrap regions");
    }
    beaconManager.unbind(beaconConsumer);
}
 
開發者ID:SiliconLabs,項目名稱:thunderboard-android,代碼行數:20,代碼來源:ThunderBoardBootstrap.java

示例14: didEnterRegion

import org.altbeacon.beacon.Region; //導入依賴的package包/類
@Override
public void didEnterRegion(Region arg0) {
    Log.d(TAG, "did enter region.");
    if (!haveDetectedBeaconsSinceBoot) {
        Log.d(TAG, "auto launching MainActivity");

        Intent intent = new Intent(this, BeaconActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        this.startActivity(intent);
        haveDetectedBeaconsSinceBoot = true;
    } else {
        if (beaconActivity != null) {
            // If the Monitoring Activity is visible, we log info about the beacons we have
            // seen on its display
            beaconActivity.logToDisplay("I see a beacon again" );
        } else {
            Log.d(TAG, "Sending notification.");
            sendNotification();
        }
    }
}
 
開發者ID:MycroftAI,項目名稱:Mycroft-Android,代碼行數:23,代碼來源:MycroftApplication.java

示例15: onBeaconServiceConnect

import org.altbeacon.beacon.Region; //導入依賴的package包/類
@Override
public void onBeaconServiceConnect() {
    beaconManager.setRangeNotifier(new RangeNotifier() {
        @Override
        public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
            if (beacons.size() > 0) {
                //EditText editText = (EditText)RangingActivity.this.findViewById(R.id.rangingText);
                Beacon firstBeacon = beacons.iterator().next();
                logToDisplay("The first beacon "
                        + firstBeacon.toString() + " is about "
                        + firstBeacon.getDistance() + " meters away.");
            }
        }

    });

    try {
        beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
    } catch (RemoteException e) {   }
}
 
開發者ID:MycroftAI,項目名稱:Mycroft-Android,代碼行數:21,代碼來源:RangingActivity.java


注:本文中的org.altbeacon.beacon.Region類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。