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


Java Beacon类代码示例

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


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

示例1: scan

import com.estimote.sdk.Beacon; //导入依赖的package包/类
public void scan(){
    beaconManager = new BeaconManager(c);
    //final RefreshingDialog dialog = new RefreshingDialog(c);
    //dialog.createRefreshingDialog();
    startScanning();

    beaconManager.setRangingListener(new BeaconManager.RangingListener() {
        @Override
        public void onBeaconsDiscovered(Region region, List<Beacon> list) {
            for(Beacon b : list){
                addBeacon(b);
            }
        }
    });

}
 
开发者ID:donniepropst,项目名称:note.cntxt,代码行数:17,代码来源:BeaconDetailsDetector.java

示例2: onSingleEntryInDetectedBeacons

import com.estimote.sdk.Beacon; //导入依赖的package包/类
private void onSingleEntryInDetectedBeacons(final Beacon detectedBeacon) {
    switch (computeProximity(detectedBeacon)) {
        case IMMEDIATE:
            scaningHintListener.onImmediateProximity();
            break;
        case NEAR:
            scaningHintListener.onNearProximity();
            break;
        case FAR:
            scaningHintListener.onFarProximity();
            break;
        case UNKNOWN:
            scaningHintListener.onUnknownProximity();
            break;
    }
}
 
开发者ID:DroidsOnRoids,项目名称:EstimoteBeaconsDemo,代码行数:17,代码来源:BeaconsService.java

示例3: PiggateEstimoteBridge

import com.estimote.sdk.Beacon; //导入依赖的package包/类
public PiggateEstimoteBridge(Piggate piggate){
    _piggate=piggate;
    String UUID=Piggate.getMetadata(piggate.getApplicationContext(), "com.piggate.sdk.ApplicationUUID"); //Set the UUID
    _region = new Region(piggate.getApplicationContext().getPackageName()+"-"+UUID, UUID, null, null); //Set the region
    _beaconManager = new BeaconManager(piggate.getApplicationContext()); //Set the beacon manager
    _beaconManager.setRangingListener(new BeaconManager.RangingListener() { //Set the ranging listener
        //Handles the actions when the beacon are discovered
        //Put the beacons into a list and send them into the piggatecallback object
        @Override
        synchronized public void onBeaconsDiscovered(Region region, List<Beacon> beacons) {
            final ArrayList<PiggateBeacon> listBeacon=new ArrayList<PiggateBeacon>();
            final ArrayList<PiggateBeacon> listBeacon2;
            Beacon beacon;
            for(int x=0;x<beacons.size();x++){
                beacon=beacons.get(x);
                listBeacon.add(new PiggateBeacon(beacon.getProximityUUID(),beacon.getMacAddress(),beacon.getMajor(),beacon.getMinor(),beacon.getMeasuredPower(),beacon.getRssi()));
            }
            listBeacon2=PiggateBeacon.registryBeacon(listBeacon);
            if(listBeacon2.size()>0)
                _piggatecallback.GetNewBeacons(listBeacon2);
            PiggateBeacon.addPendingBeacons(listBeacon);
            _piggatecallback.GetBeacons(listBeacon);
        }
    });
}
 
开发者ID:piggate,项目名称:Piggate-Android-SDK,代码行数:26,代码来源:PiggateEstimoteBridge.java

示例4: onBeaconsDiscovered

import com.estimote.sdk.Beacon; //导入依赖的package包/类
/******** BeaconManager.RangingListener Implementation ********/

    @Override
    public void onBeaconsDiscovered(Region region, List<Beacon> list) {
        Timber.i("Beacons discovered in region %s are %d ", region.getIdentifier(), list.size());
        for (Beacon beacon : list) {
            Timber.i(beacon.toString());
        }
        Beacon nearestBeacon = calculateNearestBeacon(list);
        if (nearestBeacon == null) return;

        Timber.i("Nearest beacon is " + nearestBeacon);
        if (isSameAsTodayLatestEncounter(nearestBeacon)) {
            Timber.i("Skipping encounter. Beacon is same as today's latest successful encounter");
        } else {
            performEncounter(nearestBeacon);
        }
    }
 
开发者ID:ribot,项目名称:ribot-app-android,代码行数:19,代码来源:AutoCheckInService.java

示例5: calculateNearestBeacon

import com.estimote.sdk.Beacon; //导入依赖的package包/类
/******** Helper methods ********/

    @Nullable
    private Beacon calculateNearestBeacon(Collection<Beacon> beacons) {
        Beacon nearestBeacon = null;
        Double shortestDistance = null;
        for (Beacon beacon : beacons) {
            double distance = Utils.computeAccuracy(beacon);
            if (nearestBeacon != null) {
                if (distance < shortestDistance) {
                    nearestBeacon = beacon;
                    shortestDistance = distance;
                }
            } else {
                nearestBeacon = beacon;
                shortestDistance = distance;
            }
        }
        return nearestBeacon;
    }
 
开发者ID:ribot,项目名称:ribot-app-android,代码行数:21,代码来源:AutoCheckInService.java

示例6: onEnteredRegion

import com.estimote.sdk.Beacon; //导入依赖的package包/类
@Override
public void onEnteredRegion(Region region, List<Beacon> beacons)
{
    LogUtil.d("onEnteredRegion. Region entered: " + region.toString());

    for (Beacon beacon : beacons)
    {
        LogUtil.d(beacon.toString());

        if (beacon.getMajor() == MAJOR)
        {
            WifiManager manager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
            manager.setWifiEnabled(true);

            setScanningMode(ScanningModes.HOME_MODE);
        }
    }
}
 
开发者ID:zakaprov,项目名称:network-switcher,代码行数:19,代码来源:BeaconServiceReceiver.java

示例7: connectToService

import com.estimote.sdk.Beacon; //导入依赖的package包/类
private void connectToService() {
  getActionBar().setSubtitle("Scanning...");
  adapter.replaceWith(Collections.<Beacon>emptyList());
  beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
    @Override
    public void onServiceReady() {
      try {
        beaconManager.startRanging(ALL_ESTIMOTE_BEACONS_REGION);
      } catch (RemoteException e) {
        Toast.makeText(ListBeaconsActivity.this, "Cannot start ranging, something terrible happened",
            Toast.LENGTH_LONG).show();
        Log.e(TAG, "Cannot start ranging", e);
      }
    }
  });
}
 
开发者ID:travelbird,项目名称:hackathon-estimote-demo,代码行数:17,代码来源:ListBeaconsActivity.java

示例8: getLocation

import com.estimote.sdk.Beacon; //导入依赖的package包/类
public void getLocation(Beacon beacon, APIHandler<Location> handler){

        // Iterate through locations
        for(Location loc: mLocations.values()){
            Beacon locBeac = loc.beacon;
            if(locBeac.getMacAddress().equals(beacon.getMacAddress()) &&
                    locBeac.getProximityUUID().equals(beacon.getProximityUUID()) &&
                    locBeac.getMajor() == beacon.getMajor() &&
                    locBeac.getMinor() == beacon.getMinor()){

                handler.onSuccess(loc);
                return;
            }

        }

        handler.onFailure(null, -1, "Can't find Location");
    }
 
开发者ID:hackathon-2014,项目名称:disciples-of-duarte-repo,代码行数:19,代码来源:UserSession.java

示例9: Location

import com.estimote.sdk.Beacon; //导入依赖的package包/类
public Location(JSONObject json){
    id = json.optLong("id");
    name = json.optString("name");
    companyId = json.optLong("company_id");
    companyName = json.optString("company_name");
    companyIcon = json.optString("company_icon");
    range = (float) json.optDouble("range");

    JSONObject beaconJson = json.optJSONObject("beacon");
    String mac_addr = beaconJson.optString("mac");
    int major = beaconJson.optInt("major");
    int minor = beaconJson.optInt("minor");
    beacon = new Beacon("B9407F30-F5F8-466E-AFF9-25556B57FE6D", "", mac_addr, major, minor, 0, 0);

    JSONArray cats = json.optJSONArray("categories");
    int N = cats.length();
    for(int i=0; i<N; i++){
        String category = cats.optString(i);
        categories.add(category);
    }

}
 
开发者ID:hackathon-2014,项目名称:disciples-of-duarte-repo,代码行数:23,代码来源:Location.java

示例10: onBeaconsDiscovered

import com.estimote.sdk.Beacon; //导入依赖的package包/类
@Override
public void onBeaconsDiscovered(Region region, List<Beacon> list)
{
	dataReceived();

	for (Beacon beacon : list)
	{
		beaconDistances.put(getIdentifier(beacon), calculateDistance(beacon));
	}
}
 
开发者ID:hcmlab,项目名称:ssj,代码行数:11,代码来源:BeaconListener.java

示例11: getIdentifier

import com.estimote.sdk.Beacon; //导入依赖的package包/类
private String getIdentifier(Beacon beacon)
{
	String key = beacon.getMacAddress().toStandardString();

	if (idMode == EstimoteBeacon.IdentificationMode.UUID_MAJOR_MINOR)
	{
		key = beacon.getProximityUUID() + ":" + beacon.getMajor() + ":" + beacon.getMinor();
	}

	return key;
}
 
开发者ID:hcmlab,项目名称:ssj,代码行数:12,代码来源:BeaconListener.java

示例12: calculateDistance

import com.estimote.sdk.Beacon; //导入依赖的package包/类
private double calculateDistance(Beacon beacon)
{
	double calculatedDistance = Math.pow(10d, ((double) beacon.getMeasuredPower() - beacon.getRssi()) / (10 * 4));
	double estimoteDistance = Utils.computeAccuracy(beacon);

	return (calculatedDistance + estimoteDistance) / 2.0;
}
 
开发者ID:hcmlab,项目名称:ssj,代码行数:8,代码来源:BeaconListener.java

示例13: setRangingListener

import com.estimote.sdk.Beacon; //导入依赖的package包/类
private void setRangingListener() {
    beaconManager.setRangingListener(new BeaconManager.RangingListener() {
        @Override
        public void onBeaconsDiscovered(Region region, final List<Beacon> beacons) {
            // Note that results are not delivered on UI thread.
            WritableMap params = Arguments.createMap();
            Log.v(BEACON, "Found amount: " + beacons.size());
            params.putString("beacons", new Gson().toJson(beacons));
            sendEvent(reactContext, "beaconsDidRange", params);
        }
    });
}
 
开发者ID:ti8m,项目名称:react-native-ibeacon-android,代码行数:13,代码来源:RNBeacon.java

示例14: NearestBeaconManager

import com.estimote.sdk.Beacon; //导入依赖的package包/类
public NearestBeaconManager(Context context, List<BeaconID> beaconIDs) {
    this.beaconIDs = beaconIDs;

    beaconManager = new BeaconManager(context);
    beaconManager.setRangingListener(new BeaconManager.RangingListener() {
        @Override
        public void onBeaconsDiscovered(Region region, List<Beacon> list) {
            checkForNearestBeacon(list);
        }
    });
}
 
开发者ID:rominirani,项目名称:Estimote-Slack,代码行数:12,代码来源:NearestBeaconManager.java

示例15: checkForNearestBeacon

import com.estimote.sdk.Beacon; //导入依赖的package包/类
private void checkForNearestBeacon(List<Beacon> allBeacons) {
    List<Beacon> beaconsOfInterest = filterOutBeaconsByIDs(allBeacons, beaconIDs);
    Beacon nearestBeacon = findNearestBeacon(beaconsOfInterest);
    if (nearestBeacon != null) {
        BeaconID nearestBeaconID = BeaconID.fromBeacon(nearestBeacon);
        if (!nearestBeaconID.equals(currentlyNearestBeaconID) || !firstEventSent) {
            updateNearestBeacon(nearestBeaconID);
        }
    } else if (currentlyNearestBeaconID != null || !firstEventSent) {
        updateNearestBeacon(null);
    }
}
 
开发者ID:rominirani,项目名称:Estimote-Slack,代码行数:13,代码来源:NearestBeaconManager.java


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