本文整理汇总了Java中com.radiusnetworks.ibeacon.Region类的典型用法代码示例。如果您正苦于以下问题:Java Region类的具体用法?Java Region怎么用?Java Region使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Region类属于com.radiusnetworks.ibeacon包,在下文中一共展示了Region类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: startRangingBeaconsInRegion
import com.radiusnetworks.ibeacon.Region; //导入依赖的package包/类
/**
* methods for clients
*/
public void startRangingBeaconsInRegion(Region region, Callback callback) {
synchronized (rangedRegionState) {
if (rangedRegionState.containsKey(region)) {
Log.i(TAG, "Already ranging that region -- will replace existing region.");
rangedRegionState.remove(region); // need to remove it, otherwise the old object will be retained because they are .equal
}
rangedRegionState.put(region, new RangeState(callback));
}
if (IBeaconManager.debug)
Log.d(TAG, "Currently ranging " + rangedRegionState.size() + " regions.");
if (!scanningEnabled) {
enableScanning();
}
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:19,代码来源:IBeaconService.java
示例2: getMonitoredRegions
import com.radiusnetworks.ibeacon.Region; //导入依赖的package包/类
private void getMonitoredRegions(CallbackContext callbackContext) {
_handleCallSafely(callbackContext, new ILocationManagerCommand() {
@Override
public PluginResult run() {
try {
Collection<Region> regions = iBeaconManager.getMonitoredRegions();
JSONArray regionArray = new JSONArray();
for (Region region : regions) {
regionArray.put(mapOfRegion(region));
}
return new PluginResult(PluginResult.Status.OK,regionArray);
} catch (JSONException e) {
debugWarn("'getMonitoredRegions' exception: "+ e.getMessage());
return new PluginResult(PluginResult.Status.ERROR,e.getMessage());
}
}
});
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:23,代码来源:LocationManager.java
示例3: getRangedRegions
import com.radiusnetworks.ibeacon.Region; //导入依赖的package包/类
private void getRangedRegions(CallbackContext callbackContext) {
_handleCallSafely(callbackContext, new ILocationManagerCommand() {
@Override
public PluginResult run() {
try {
Collection<Region> regions = iBeaconManager.getRangedRegions();
JSONArray regionArray = new JSONArray();
for (Region region : regions) {
regionArray.put(mapOfRegion(region));
}
return new PluginResult(PluginResult.Status.OK,regionArray);
} catch (JSONException e) {
debugWarn("'getRangedRegions' exception: "+ e.getMessage());
return new PluginResult(PluginResult.Status.ERROR,e.getMessage());
}
}
});
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:22,代码来源:LocationManager.java
示例4: parseRegion
import com.radiusnetworks.ibeacon.Region; //导入依赖的package包/类
private Region parseRegion(JSONObject json) throws JSONException, InvalidKeyException, UnsupportedOperationException {
if (!json.has("typeName"))
throw new InvalidKeyException("'typeName' is missing, cannot parse Region.");
if (!json.has("identifier"))
throw new InvalidKeyException("'identifier' is missing, cannot parse Region.");
String typeName = json.getString("typeName");
if (typeName.equals("BeaconRegion")) {
return parseBeaconRegion(json);
} else if (typeName.equals("CircularRegion")) {
return parseCircularRegion(json);
} else {
throw new UnsupportedOperationException("Unsupported region type");
}
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:20,代码来源:LocationManager.java
示例5: parseCircularRegion
import com.radiusnetworks.ibeacon.Region; //导入依赖的package包/类
private Region parseCircularRegion(JSONObject json) throws JSONException, InvalidKeyException, UnsupportedOperationException {
if (!json.has("latitude"))
throw new InvalidKeyException("'latitude' is missing, cannot parse CircularRegion.");
if (!json.has("longitude"))
throw new InvalidKeyException("'longitude' is missing, cannot parse CircularRegion.");
if (!json.has("radius"))
throw new InvalidKeyException("'radius' is missing, cannot parse CircularRegion.");
/*String identifier = json.getString("identifier");
double latitude = json.getDouble("latitude");
double longitude = json.getDouble("longitude");
double radius = json.getDouble("radius");
*/
throw new UnsupportedOperationException("Circular regions are not supported at present");
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:19,代码来源:LocationManager.java
示例6: mapOfBeaconRegion
import com.radiusnetworks.ibeacon.Region; //导入依赖的package包/类
private JSONObject mapOfBeaconRegion(Region region) throws JSONException {
JSONObject dict = new JSONObject();
// identifier
if (region.getUniqueId() != null) {
dict.put("identifier", region.getUniqueId());
}
dict.put("uuid", region.getProximityUuid());
if (region.getMajor()!=null) {
dict.put("major", region.getMajor());
}
if (region.getMinor()!=null) {
dict.put("minor", region.getMinor());
}
dict.put("typeName", "BeaconRegion");
return dict;
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:24,代码来源:LocationManager.java
示例7: addRegion
import com.radiusnetworks.ibeacon.Region; //导入依赖的package包/类
private void addRegion(JSONArray data, CallbackContext callbackContext) {
final JSONArray data2 = data;
final CallbackContext callbackContext2 = callbackContext;
cordova.getThreadPool().execute(new Runnable() {
@Override
public void run() {
try {
iBeaconManager.startMonitoringBeaconsInRegion(new Region(data2.optString(0), data2.optString(1), null, null));
callbackContext2.success();
} catch (RemoteException e) {
callbackContext2.error("Could not add region");
}
}
});
}
开发者ID:drivensystems,项目名称:cordova-yoik-ibeacon,代码行数:20,代码来源:YoikIBeacon.java
示例8: onIBeaconServiceConnect
import com.radiusnetworks.ibeacon.Region; //导入依赖的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
示例9: handleMessage
import com.radiusnetworks.ibeacon.Region; //导入依赖的package包/类
@Override
public void handleMessage(Message msg) {
Region region = (Region) msg.obj;
if( msg.what == BeaconEvent.REGION_ENTER.ordinal() ) {
if( !mRegionsToLeave.remove(region.getUniqueId()) ) {
processEvent(BeaconEvent.REGION_ENTER, region);
}
} else if( msg.what == BeaconEvent.REGION_LEAVE.ordinal() ) {
if( mRegionsToLeave.remove(region.getUniqueId()) ) {
mMonitoredRegionsUniqueIds.remove(region.getUniqueId());
processEvent(BeaconEvent.REGION_LEAVE, region);
}
} else {
super.handleMessage(msg);
}
}
开发者ID:upnext,项目名称:blekit-android,代码行数:22,代码来源:BLEKitService.java
示例10: stopScanningZones
import com.radiusnetworks.ibeacon.Region; //导入依赖的package包/类
private void stopScanningZones() {
if( iBeaconManager==null ) return;
for( String monitoringUniqueId : mMonitoredRegionsUniqueIds.keySet() ) {
L.d( "stopScanningZones " + monitoringUniqueId );
try {
iBeaconManager.stopMonitoringBeaconsInRegion( new Region(monitoringUniqueId, null, null, null) );
iBeaconManager.stopRangingBeaconsInRegion(new Region(monitoringUniqueId, null, null, null));
} catch (RemoteException e) {
e.printStackTrace();
}
}
mMonitoredRegionsUniqueIds.clear();
mMonitoredBeaconIds.clear();
}
开发者ID:upnext,项目名称:blekit-android,代码行数:17,代码来源:BLEKitService.java
示例11: startScanningZones
import com.radiusnetworks.ibeacon.Region; //导入依赖的package包/类
private void startScanningZones(List<Beacon> beacons) {
L.d(". " + mBeaconManagerConnected);
if( beacons==null || !mBeaconManagerConnected ) return;
for( Beacon beacon : beacons ) {
String monitoringId = beacon.id + Rand.nextLong();
mMonitoredRegionsUniqueIds.put(monitoringId, null);
Region region = new Region( monitoringId, beacon.getProximityUid(), beacon.getMajor(), beacon.getMinor() );
L.d( "startScanningZone " + region.toString() );
try {
iBeaconManager.startMonitoringBeaconsInRegion( region );
iBeaconManager.startRangingBeaconsInRegion( region );
} catch (RemoteException e) {
e.printStackTrace();
}
}
}
开发者ID:upnext,项目名称:blekit-android,代码行数:18,代码来源:BLEKitService.java
示例12: sendEventToClients
import com.radiusnetworks.ibeacon.Region; //导入依赖的package包/类
private void sendEventToClients( final BeaconEvent event, final Region region, final String beaconId ) {
L.d( event.name() + " " + region.getMajor()+"-"+region.getMinor() );
final Proximity newProximity = Proximity.fromBeaconEvent(event);
if( newProximity == mMonitoredBeaconIds.get(beaconId) ) {
L.d( "proximity is same as old value, not broadcasting" );
return;
}
mMonitoredBeaconIds.put( beaconId, newProximity );
persistBeaconStates();
for( String pkg : clients.keySet() ) {
BLEKitClient client = clients.get(pkg);
L.d("." + pkg);
if(client!=null && isAnyBeaconInRegion(client.getMonitoredBeaconIDs(), region)) {
client.call( this, event, beaconId );
}
}
}
开发者ID:upnext,项目名称:blekit-android,代码行数:22,代码来源:BLEKitService.java
示例13: stopRangingBeaconsInRegion
import com.radiusnetworks.ibeacon.Region; //导入依赖的package包/类
public void stopRangingBeaconsInRegion(Region region) {
synchronized (rangedRegionState) {
rangedRegionState.remove(region);
}
if (IBeaconManager.debug)
Log.d(TAG, "Currently ranging " + rangedRegionState.size() + " regions.");
if (scanningEnabled && rangedRegionState.size() == 0 && monitoredRegionState.size() == 0) {
disableScanning();
}
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:12,代码来源:IBeaconService.java
示例14: startMonitoringBeaconsInRegion
import com.radiusnetworks.ibeacon.Region; //导入依赖的package包/类
public void startMonitoringBeaconsInRegion(Region region, Callback callback) {
if (IBeaconManager.debug) Log.d(TAG, "startMonitoring called");
synchronized (monitoredRegionState) {
if (monitoredRegionState.containsKey(region)) {
Log.i(TAG, "Already monitoring that region -- will replace existing region monitor.");
monitoredRegionState.remove(region); // need to remove it, otherwise the old object will be retained because they are .equal
}
monitoredRegionState.put(region, new MonitorState(callback));
}
if (IBeaconManager.debug)
Log.d(TAG, "Currently monitoring " + monitoredRegionState.size() + " regions.");
if (!scanningEnabled) {
enableScanning();
}
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:16,代码来源:IBeaconService.java
示例15: stopMonitoringBeaconsInRegion
import com.radiusnetworks.ibeacon.Region; //导入依赖的package包/类
public void stopMonitoringBeaconsInRegion(Region region) {
if (IBeaconManager.debug) Log.d(TAG, "stopMonitoring called");
synchronized (monitoredRegionState) {
monitoredRegionState.remove(region);
}
if (IBeaconManager.debug)
Log.d(TAG, "Currently monitoring " + monitoredRegionState.size() + " regions.");
if (scanningEnabled && rangedRegionState.size() == 0 && monitoredRegionState.size() == 0) {
disableScanning();
}
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:12,代码来源:IBeaconService.java
示例16: processRangeData
import com.radiusnetworks.ibeacon.Region; //导入依赖的package包/类
private void processRangeData() {
Iterator<Region> regionIterator = rangedRegionState.keySet().iterator();
while (regionIterator.hasNext()) {
Region region = regionIterator.next();
RangeState rangeState = rangedRegionState.get(region);
if (IBeaconManager.debug)
Log.d(TAG, "Calling ranging callback with " + rangeState.getIBeacons().size() + " iBeacons");
rangeState.getCallback().call(IBeaconService.this, "rangingData", new RangingData(rangeState.getIBeacons(), region));
synchronized (rangeState) {
rangeState.clearIBeacons();
}
}
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:15,代码来源:IBeaconService.java
示例17: processExpiredMonitors
import com.radiusnetworks.ibeacon.Region; //导入依赖的package包/类
private void processExpiredMonitors() {
Iterator<Region> monitoredRegionIterator = monitoredRegionState.keySet().iterator();
while (monitoredRegionIterator.hasNext()) {
Region region = monitoredRegionIterator.next();
MonitorState state = monitoredRegionState.get(region);
if (state.isNewlyOutside()) {
if (IBeaconManager.debug) Log.d(TAG, "found a monitor that expired: " + region);
state.getCallback().call(IBeaconService.this, "monitoringData", new MonitoringData(state.isInside(), region));
}
}
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:12,代码来源:IBeaconService.java
示例18: matchingRegions
import com.radiusnetworks.ibeacon.Region; //导入依赖的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
示例19: createRangingCallbacks
import com.radiusnetworks.ibeacon.Region; //导入依赖的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
示例20: parseBeaconRegion
import com.radiusnetworks.ibeacon.Region; //导入依赖的package包/类
private Region parseBeaconRegion(JSONObject json) throws JSONException, UnsupportedOperationException {
String identifier = json.getString("identifier");
//For Android, uuid can be null when scanning for all beacons (I think)
String uuid = json.has("uuid")&&!json.isNull("uuid") ? json.getString("uuid") : null;
Integer major = json.has("major")&&!json.isNull("major") ? json.getInt("major") : null;
Integer minor = json.has("minor")&&!json.isNull("minor") ? json.getInt("minor") : null;
if (major==null && minor!=null)
throw new UnsupportedOperationException("Unsupported combination of 'major' and 'minor' parameters.");
return new Region(identifier,uuid,major,minor);
}
开发者ID:KillerCodeMonkey,项目名称:iBeacon-nfc,代码行数:15,代码来源:LocationManager.java
注:本文中的com.radiusnetworks.ibeacon.Region类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论