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


Java Region类代码示例

本文整理汇总了Java中com.radiusnetworks.ibeacon.Region的典型用法代码示例。如果您正苦于以下问题:Java Region类的具体用法?Java Region怎么用?Java Region使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Region类属于com.radiusnetworks.ibeacon包,在下文中一共展示了Region类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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