本文整理汇总了Java中com.radiusnetworks.ibeacon.IBeacon类的典型用法代码示例。如果您正苦于以下问题:Java IBeacon类的具体用法?Java IBeacon怎么用?Java IBeacon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IBeacon类属于com.radiusnetworks.ibeacon包,在下文中一共展示了IBeacon类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: mapOfBeacon
import com.radiusnetworks.ibeacon.IBeacon; //导入依赖的package包/类
private JSONObject mapOfBeacon(IBeacon region) throws JSONException {
JSONObject dict = new JSONObject();
//beacon id
dict.put("uuid", region.getProximityUuid());
dict.put("major", region.getMajor());
dict.put("minor", region.getMinor());
// proximity
dict.put("proximity", nameOfProximity(region.getProximity()));
// signal strength and transmission power
dict.put("rssi", region.getRssi());
dict.put("tx", region.getTxPower());
// accuracy = rough distance estimate limited to two decimal places (in metres)
// NO NOT ASSUME THIS IS ACCURATE - it is effected by radio interference and obstacles
dict.put("accuracy", Math.round(region.getAccuracy()*100.0)/100.0);
return dict;
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:22,代码来源:LocationManager.java
示例2: onIBeaconServiceConnect
import com.radiusnetworks.ibeacon.IBeacon; //导入依赖的package包/类
@Override
public void onIBeaconServiceConnect() {
iBeaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<IBeacon> iBeacons, Region region) {
if (iBeacons.size() > 0) {
EditText editText = (EditText)RangingActivity.this
.findViewById(R.id.rangingText);
IBeacon aBeacon = iBeacons.iterator().next();
logToDisplay("Num Beacons:" + iBeacons.size() + " The first iBeacon I see is about "+ aBeacon.getAccuracy()+" meters away. " + aBeacon.getProximityUuid());
}
}
});
try {
iBeaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
} catch (RemoteException e) { }
}
开发者ID:skylight1,项目名称:beaconscan,代码行数:20,代码来源:RangingActivity.java
示例3: setLocation
import com.radiusnetworks.ibeacon.IBeacon; //导入依赖的package包/类
private void setLocation(IBeacon iBeacon) {
mLastChanged = new DateTime();
if (iBeacon == null) {
leaveCurrentZone();
return;
}
Puck newClosestPuck = mPuckManager.forIBeacon(iBeacon);
if (newClosestPuck == null) {
if (iBeacon.getProximity() == IBeacon.PROXIMITY_IMMEDIATE) {
EventBus.postEvent(Trigger.TRIGGER_ZONE_DISCOVERED, iBeacon);
} else {
leaveCurrentZone();
}
} else if (!newClosestPuck.equals(mClosestPuck)) {
leaveCurrentZone();
enterNewZone(newClosestPuck);
}
}
开发者ID:NordicPlayground,项目名称:puck-central-android,代码行数:21,代码来源:LocationManager.java
示例4: doInBackground
import com.radiusnetworks.ibeacon.IBeacon; //导入依赖的package包/类
@Override
protected Void doInBackground(ScanData... params) {
ScanData scanData = params[0];
IBeacon iBeacon = IBeacon.fromScanData(scanData.scanRecord,
scanData.rssi, scanData.device);
if (iBeacon != null) {
processIBeaconFromScan(iBeacon);
}
bluetoothCrashResolver.notifyScannedDevice(scanData.device, (BluetoothAdapter.LeScanCallback)getLeScanCallback());
return null;
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:14,代码来源:IBeaconService.java
示例5: matchingRegions
import com.radiusnetworks.ibeacon.IBeacon; //导入依赖的package包/类
private List<Region> matchingRegions(IBeacon iBeacon, Collection<Region> regions) {
List<Region> matched = new ArrayList<Region>();
Iterator<Region> regionIterator = regions.iterator();
while (regionIterator.hasNext()) {
Region region = regionIterator.next();
if (region.matchesIBeacon(iBeacon)) {
matched.add(region);
} else {
if (IBeaconManager.debug) Log.d(TAG, "This region does not match: " + region);
}
}
return matched;
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:16,代码来源:IBeaconService.java
示例6: fromIBeacons
import com.radiusnetworks.ibeacon.IBeacon; //导入依赖的package包/类
public static Collection<IBeaconData> fromIBeacons(Collection<IBeacon> iBeacons) {
ArrayList<IBeaconData> iBeaconDatas = new ArrayList<IBeaconData>();
Iterator<IBeacon> iBeaconIterator = iBeacons.iterator();
while (iBeaconIterator.hasNext()) {
iBeaconDatas.add(new IBeaconData(iBeaconIterator.next()));
}
return iBeaconDatas;
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:9,代码来源:IBeaconData.java
示例7: fromIBeaconDatas
import com.radiusnetworks.ibeacon.IBeacon; //导入依赖的package包/类
public static Collection<IBeacon> fromIBeaconDatas(Collection<IBeaconData> iBeaconDatas) {
ArrayList<IBeacon> iBeacons = new ArrayList<IBeacon>();
if (iBeaconDatas != null) {
Iterator<IBeaconData> iBeaconIterator = iBeaconDatas.iterator();
while (iBeaconIterator.hasNext()) {
iBeacons.add(iBeaconIterator.next());
}
}
return iBeacons;
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:11,代码来源:IBeaconData.java
示例8: requestIBeaconData
import com.radiusnetworks.ibeacon.IBeacon; //导入依赖的package包/类
@Override
public void requestIBeaconData(IBeacon iBeacon, final IBeaconDataNotifier notifier) {
final Handler handler = new Handler();
handler.post(new Runnable() {
@Override
public void run() {
notifier.iBeaconDataUpdate(null, null, new DataProviderException("Please upgrade to the Pro version of the Android iBeacon Library."));
}
});
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:11,代码来源:NullIBeaconDataFactory.java
示例9: addIBeacon
import com.radiusnetworks.ibeacon.IBeacon; //导入依赖的package包/类
public void addIBeacon(IBeacon iBeacon) {
if (rangedIBeacons.containsKey(iBeacon)) {
RangedIBeacon rangedIBeacon = rangedIBeacons.get(iBeacon);
if (IBeaconManager.debug) Log.d(TAG, "adding "+iBeacon.getProximityUuid()+" to existing range for: "+rangedIBeacon.getProximityUuid() );
rangedIBeacon.addRangeMeasurement(iBeacon.getRssi());
}
else {
if (IBeaconManager.debug) Log.d(TAG, "adding "+iBeacon.getProximityUuid()+" to new rangedIBeacon");
rangedIBeacons.put(iBeacon, new RangedIBeacon(iBeacon));
}
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:12,代码来源:RangingTracker.java
示例10: getIBeacons
import com.radiusnetworks.ibeacon.IBeacon; //导入依赖的package包/类
public synchronized Collection<IBeacon> getIBeacons() {
ArrayList<IBeacon> iBeacons = new ArrayList<IBeacon>();
Iterator<RangedIBeacon> iterator = rangedIBeacons.values().iterator();
while (iterator.hasNext()) {
RangedIBeacon rangedIBeacon = iterator.next();
if (!rangedIBeacon.allMeasurementsExpired()) {
iBeacons.add(rangedIBeacon);
}
}
return iBeacons;
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:12,代码来源:RangingTracker.java
示例11: createRangingCallbacks
import com.radiusnetworks.ibeacon.IBeacon; //导入依赖的package包/类
private void createRangingCallbacks(final CallbackContext callbackContext) {
iBeaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(final Collection<IBeacon> iBeacons, final Region region) {
threadPoolExecutor.execute(new Runnable() {
public void run() {
try {
JSONObject data = new JSONObject();
JSONArray beaconData = new JSONArray();
for (IBeacon beacon : iBeacons) {
beaconData.put(mapOfBeacon(beacon));
}
data.put("eventType", "didRangeBeaconsInRegion");
data.put("region", mapOfRegion(region));
data.put("beacons", beaconData);
debugLog("didRangeBeacons: "+ data.toString());
//send and keep reference to callback
PluginResult result = new PluginResult(PluginResult.Status.OK,data);
result.setKeepCallback(true);
callbackContext.sendPluginResult(result);
} catch (Exception e) {
Log.e(TAG, "'rangingBeaconsDidFailForRegion' exception "+e.getCause());
beaconServiceNotifier.rangingBeaconsDidFailForRegion(region, e);
}
}
});
}
});
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:38,代码来源:LocationManager.java
示例12: nameOfProximity
import com.radiusnetworks.ibeacon.IBeacon; //导入依赖的package包/类
private String nameOfProximity(int proximity) {
switch (proximity) {
case IBeacon.PROXIMITY_NEAR:
return "ProximityNear";
case IBeacon.PROXIMITY_FAR:
return "ProximityFar";
case IBeacon.PROXIMITY_IMMEDIATE:
return "ProximityImmediate";
case IBeacon.PROXIMITY_UNKNOWN:
return "ProximityUnknown";
default:
return "ErrorProximityValueUnknown";
}
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:15,代码来源:LocationManager.java
示例13: iBeaconDataUpdate
import com.radiusnetworks.ibeacon.IBeacon; //导入依赖的package包/类
@Override
public void iBeaconDataUpdate(IBeacon iBeacon, IBeaconData iBeaconData, DataProviderException e) {
if (e != null) {
Log.d(TAG, "data fetch error:"+e);
}
if (iBeaconData != null) {
String displayString = iBeacon.getProximityUuid()+" "+iBeacon.getMajor()+" "+iBeacon.getMinor()+"\n"+"Welcome message:"+iBeaconData.get("welcomeMessage");
}
}
开发者ID:drivensystems,项目名称:cordova-yoik-ibeacon,代码行数:11,代码来源:YoikIBeacon.java
示例14: sendIbeaconEvent
import com.radiusnetworks.ibeacon.IBeacon; //导入依赖的package包/类
private void sendIbeaconEvent(IBeacon iBeacon, Region region, Integer range)
{
try {
Log.d(TAG, "Firing Event");
JSONObject obj = new JSONObject();
obj.put("uuid", iBeacon.getProximityUuid());
obj.put("major", iBeacon.getMajor());
obj.put("minor", iBeacon.getMinor());
obj.put("range", proximityText(range));
obj.put("identifier", region.getUniqueId());
JSONObject result = new JSONObject();
result.put("ibeacon", obj);
final String jsStatement = String.format("cordova.fireDocumentEvent('ibeacon', %s);", result.toString());
cordova.getActivity().runOnUiThread(
new Runnable() {
@Override
public void run() {
webView.loadUrl("javascript:" + jsStatement);
}
}
);
} catch (JSONException e) {
e.printStackTrace();
}
}
开发者ID:drivensystems,项目名称:cordova-yoik-ibeacon,代码行数:31,代码来源:YoikIBeacon.java
示例15: proximityText
import com.radiusnetworks.ibeacon.IBeacon; //导入依赖的package包/类
private String proximityText(Integer proximity) {
switch (proximity) {
case PROXIMITY_NIGH:
return "nigh";
case IBeacon.PROXIMITY_NEAR:
return "near";
case IBeacon.PROXIMITY_FAR:
return "far";
case IBeacon.PROXIMITY_IMMEDIATE:
return "immediate";
default:
return "unknown";
}
}
开发者ID:drivensystems,项目名称:cordova-yoik-ibeacon,代码行数:15,代码来源:YoikIBeacon.java
示例16: onIBeaconServiceConnect
import com.radiusnetworks.ibeacon.IBeacon; //导入依赖的package包/类
@Override
public void onIBeaconServiceConnect() {
iBeaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<IBeacon> iBeacons, Region region) {
if(iBeacons != null) {
if (iBeacons.size() > 0) {
// iterate through each beacon found
range.clear();
for (IBeacon i : iBeacons) {
Log.d(TAG,"UUID:" + i.getProximityUuid() + " dist " + i.getAccuracy());
if(i.getProximityUuid().equals(Beacon1_UUID)) {
range.add(i.getAccuracy());
}
}
if(range.size() > 0) {
setDisplay(range);
}
}
}
}
});
try {
iBeaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
} catch (RemoteException e) { }
}
开发者ID:skylight1,项目名称:beaconscan,代码行数:30,代码来源:RangingDemoActivity.java
示例17: onIBeaconServiceConnect
import com.radiusnetworks.ibeacon.IBeacon; //导入依赖的package包/类
@Override
public void onIBeaconServiceConnect() {
final HashMap<Integer, String> names = new HashMap<>();
names.put(IBeacon.PROXIMITY_IMMEDIATE, "IMMEDIATE");
names.put(IBeacon.PROXIMITY_NEAR, "NEAR");
names.put(IBeacon.PROXIMITY_FAR, "FAR");
names.put(IBeacon.PROXIMITY_UNKNOWN, "UNKNOWN");
mIBeaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<IBeacon> iBeacons, Region region) {
L.v("[" + iBeacons.size() + "] iBeacons:");
for (IBeacon iBeacon : iBeacons) {
L.v(iBeacon.getProximityUuid() + "-" + iBeacon.getMajor() + "-" + iBeacon
.getMinor());
L.v("accuracy: " + iBeacon.getAccuracy());
L.v("proximity: " + names.get(iBeacon.getProximity()));
}
mLocationManager.updateLocation(iBeacons);
Puck location = mLocationManager.getCurrentLocation();
L.v("Current location: " + location);
}
});
try {
mIBeaconManager.startRangingBeaconsInRegion(
new Region("puckcentral", "E20A39F473F54BC4A12F17D1AD07A961", 0x1337, null));
} catch (RemoteException e) {
L.e(e);
}
}
开发者ID:NordicPlayground,项目名称:puck-central-android,代码行数:34,代码来源:LocationRangeMonitorService.java
示例18: updateLastSeenValues
import com.radiusnetworks.ibeacon.IBeacon; //导入依赖的package包/类
private void updateLastSeenValues(Collection<IBeacon> iBeacons, Region region) {
if( iBeacons==null || iBeacons.isEmpty() ) {
return;
}
final AverageIBeacon averageBeacon = mMonitoredRegionsUniqueIds.get( region.getUniqueId() );
if( averageBeacon!=null ) {
averageBeacon.setLastSeen( System.currentTimeMillis() );
}
}
开发者ID:upnext,项目名称:blekit-android,代码行数:11,代码来源:BLEKitService.java
示例19: getClosestBeacon
import com.radiusnetworks.ibeacon.IBeacon; //导入依赖的package包/类
private IBeacon getClosestBeacon( Collection<IBeacon> iBeacons ) {
if( iBeacons==null || iBeacons.isEmpty() ) return null;
final List<IBeacon> list = (List<IBeacon>) iBeacons;
IBeacon closest = list.get(0);
for( IBeacon beacon : list ) {
if( beacon.getAccuracy()>=0 && beacon.getAccuracy()<closest.getAccuracy() ) {
closest = beacon;
}
}
return closest;
}
开发者ID:upnext,项目名称:blekit-android,代码行数:12,代码来源:BLEKitService.java
示例20: RangingData
import com.radiusnetworks.ibeacon.IBeacon; //导入依赖的package包/类
public RangingData (Collection<IBeacon> iBeacons, Region region) {
synchronized (iBeacons) {
this.iBeaconDatas = IBeaconData.fromIBeacons(iBeacons);
}
this.regionData = new RegionData(region);
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:7,代码来源:RangingData.java
注:本文中的com.radiusnetworks.ibeacon.IBeacon类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论