本文整理汇总了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);
}
}
});
}
示例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;
}
}
示例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);
}
});
}
示例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);
}
}
示例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;
}
示例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);
}
}
}
示例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);
}
}
});
}
示例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");
}
示例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);
}
}
示例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));
}
}
示例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;
}
示例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;
}
示例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);
}
});
}
示例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);
}
});
}
示例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);
}
}