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


Java RangeNotifier类代码示例

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


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

示例1: onBeaconServiceConnect

import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
@Override
public void onBeaconServiceConnect() {
    mBeaconManager.setRangeNotifier(new RangeNotifier() {
        @Override
        public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
            if (beacons.size() > 0) {
                mBeacon = beacons.iterator().next();
            }

            if (getActivity() != null) getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    loadBeacon();
                }
            });
        }
    });

    try {
        mBeaconManager.startRangingBeaconsInRegion(new Region(UNIQUE_RANGING_ID, mBeacon.getId1(), mBeacon.getId2(), mBeacon.getId3()));
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}
 
开发者ID:menvia,项目名称:farol-android-sample,代码行数:25,代码来源:BeaconFragment.java

示例2: beaconsInRegion

import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
public Observable<RxBeaconRange> beaconsInRegion() {
    return startup()
            .flatMap(new Function<Boolean, ObservableSource<RxBeaconRange>>() {
                @Override
                public ObservableSource<RxBeaconRange> apply(@NonNull Boolean aBoolean) throws Exception {
                    return Observable.create(new ObservableOnSubscribe<RxBeaconRange>() {
                        @Override
                        public void subscribe(@NonNull final ObservableEmitter<RxBeaconRange> objectObservableEmitter) throws Exception {
                            beaconManager.addRangeNotifier(new RangeNotifier() {
                                @Override
                                public void didRangeBeaconsInRegion(Collection<Beacon> collection, Region region) {
                                    objectObservableEmitter.onNext(new RxBeaconRange(collection, region));
                                }
                            });
                            beaconManager.startRangingBeaconsInRegion(getRegion());
                        }
                    });
                }
            });
}
 
开发者ID:florent37,项目名称:RxBeacon,代码行数:21,代码来源:RxBeacon.java

示例3: onBeaconServiceConnect

import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
@Override
public void onBeaconServiceConnect() {
    beaconManager.setRangeNotifier(new RangeNotifier() {
        @Override
        public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
            if (beacons.size() > 0) {
                Log.i(TAG, "The first beacon I see is about " + beacons.iterator().next().getDistance() + " meters away.");
            }
        }
    });

    try {
        beaconManager.startRangingBeaconsInRegion(new Region("com.beacon.demo", null, null, null));
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}
 
开发者ID:sahir,项目名称:eddystone-beacon,代码行数:18,代码来源:BeaconApplication.java

示例4: onBeaconServiceConnect

import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
@Override
public void onBeaconServiceConnect() {
    beaconManager.setRangeNotifier(new RangeNotifier() {
       @Override
       public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
          if (beacons.size() > 0) {
              arrListBeacon.clear();
              arrListBeacon.addAll(beacons);
              showListBeacon();
          }
       }

    });

    try {
        beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
    } catch (RemoteException e) {   }
}
 
开发者ID:VNGIoTLab,项目名称:vbluno_android_ibeacon,代码行数:19,代码来源:RangingActivity.java

示例5: onBeaconServiceConnect

import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
@Override
public void onBeaconServiceConnect() {
    beaconManager.setRangeNotifier(new RangeNotifier() {
        @Override
        public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
            if (beacons.size() > 0) {
                //EditText editText = (EditText)RangingActivity.this.findViewById(R.id.rangingText);
                Beacon firstBeacon = beacons.iterator().next();
                logToDisplay("The first beacon "
                        + firstBeacon.toString() + " is about "
                        + firstBeacon.getDistance() + " meters away.");
            }
        }

    });

    try {
        beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
    } catch (RemoteException e) {   }
}
 
开发者ID:MycroftAI,项目名称:Mycroft-Android,代码行数:21,代码来源:RangingActivity.java

示例6: onBeaconServiceConnect

import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
@Override
public void onBeaconServiceConnect() {
    beaconManager.setRangeNotifier(new RangeNotifier() {
        @Override
        public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
            final Collection<Beacon> beaconsfinal = new ArrayList<Beacon>(beacons);

            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    toolbar.setSubtitle(String.format("%d beacons discovered.", beaconsfinal.size()));
                    adapter.replaceWith(beaconsfinal);
                }
            });
        }

    });

    try {
        beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
    } catch (RemoteException e) {
        Log.d(TAG, "RemoteException");
    }
}
 
开发者ID:michalkorzen,项目名称:BLE2HCP,代码行数:25,代码来源:DiscoveryActivity.java

示例7: onBeaconServiceConnect

import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
@Override
public void onBeaconServiceConnect() {
    mBeaconManager.setRangeNotifier(new RangeNotifier() {
        @Override
        public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
            mBeacons.clear();
            if (beacons.size() > 0) {
                mBeacons.addAll(beacons);
            }

            if (getActivity() != null) getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    mAdapter.notifyDataSetChanged();
                }
            });
        }
    });

    try {
        mBeaconManager.startRangingBeaconsInRegion(new Region(UNIQUE_RANGING_ID, null, null, null));
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}
 
开发者ID:menvia,项目名称:farol-android-sample,代码行数:26,代码来源:BeaconListFragment.java

示例8: onBeaconServiceConnect

import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
@Override
public void onBeaconServiceConnect() {
    beaconManager.setRangeNotifier(new RangeNotifier() {
        @Override
        public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
            beacons_l.clear();
            beacons_l.addAll(beacons);
            logToDisplay(beacons_l);

            if (beacons.size() > 0) {
                ticks ++;
                speech(beacons_l);
            }
        }
    });

    try {
        beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
    } catch (RemoteException e) {   }
}
 
开发者ID:carlgonz,项目名称:bus-beacon,代码行数:21,代码来源:RangingActivity.java

示例9: onBeaconServiceConnect

import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
@Override
public void onBeaconServiceConnect() {
    beaconManager.setRangeNotifier(new RangeNotifier() {
        @Override
        public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
            if (beacons.size() > 0) {
                updateText(beacons.iterator().next().getDistance());
            }
        }
    });

    try {
        beaconManager.startRangingBeaconsInRegion(new Region("here", null, null, null));
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}
 
开发者ID:tmay,项目名称:BluetoothBacon,代码行数:18,代码来源:RangeBeaconActivity.java

示例10: startFullScan

import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
public void startFullScan() {
    assertServiceReady();

    if (beaconManager.getRangedRegions().contains(FULL_SCAN_REGION)) return;
    for (Region r : beaconManager.getRangedRegions()) {
        stopRanging(r);
    }

    beaconManager.setRangeNotifier(new RangeNotifier() {
        @Override
        public void didRangeBeaconsInRegion(Collection<Beacon> iBeacons, Region region) {
            postOnMainThread(new FullScanCompleteEvent(iBeacons));
        }
    });

    try {
        beaconManager.startRangingBeaconsInRegion(FULL_SCAN_REGION);
        Log.i(TAG, "Full scan started");
    } catch (RemoteException e) {
        Log.e(TAG, "Could not start full scan", e);
    }
}
 
开发者ID:cmelchior,项目名称:trifork-ibeacon-demo,代码行数:23,代码来源:BeaconController.java

示例11: onBeaconServiceConnect

import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
@Override
public void onBeaconServiceConnect() {
    beaconManager.addRangeNotifier(new RangeNotifier() {
        @Override
        public void didRangeBeaconsInRegion(final Collection<Beacon> beacons, Region region) {
            Log.d("beacons", beacons.size() + "");
            if (beacons.size() > 0) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Iterator<Beacon> beaconIterator = beacons.iterator();
                        double distance = 1000f;
                        while (beaconIterator.hasNext()) {
                            Beacon beacon = beaconIterator.next();
                            Log.i("beacons", "The first beacon I see is about " + beacon.getBluetoothAddress() + " meters away.");
                            if (beacon.getBluetoothAddress().equals("C9:FE:F5:0D:BB:3A"))
                                distance = beacon.getDistance();
                        }

                        mMainTv.setText("Min distance: " + distance);
                    }
                });

            }
        }
    });

    try {
        beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
    } catch (RemoteException e) {
    }
}
 
开发者ID:kevalpatel2106,项目名称:android-samples,代码行数:33,代码来源:MainActivity.java

示例12: ThunderBoardBootstrap

import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
public ThunderBoardBootstrap(Context context, RangeNotifier rangeNotifier, Region region) {
    this.context = context;
    this.rangeNotifier = rangeNotifier;
    beaconManager = BeaconManager.getInstanceForApplication(context);
    regions = new ArrayList<>();
    regions.add(region);
    beaconConsumer = new InternalBeaconConsumer();
    beaconManager.bind(beaconConsumer);
    Timber.d("Waiting for BeaconService connection");
}
 
开发者ID:SiliconLabs,项目名称:thunderboard-android,代码行数:11,代码来源:ThunderBoardBootstrap.java

示例13: onBeaconServiceConnect

import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
@Override
public void onBeaconServiceConnect() {
    Log.d(TAG, "On beacon connect+++++++++++++++++");
    beaconManager.setBackgroundMode(false);
    beaconManager.setRangeNotifier(new RangeNotifier() {
        @Override
        public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {

            Log.d(TAG, "++ " + beacons.size());

            if (beacons.isEmpty())
                return;
            HashMap<String, Beacon> beaconData = new HashMap<String, Beacon>();

            for (Beacon beacon : beacons) {
                beaconData.put(getBeaconId(beacon), beacon);
            }

            long time = System.currentTimeMillis();
            try {
                lock.lock();
                for (AbstractBeaconSensor sensor : sensors) {
                    sensor.setData(beaconData, time);
                }
            } finally {
                lock.unlock();
            }
        }
    });
    try {
        beaconManager.startRangingBeaconsInRegion(myRegion);
    } catch (RemoteException e) {
        Log.d(TAG, "Got exception" + e.getMessage());
    }
}
 
开发者ID:swandroid,项目名称:swan-sense-studio,代码行数:36,代码来源:BeaconSingleton.java

示例14: onBeaconServiceConnect

import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
@Override
public void onBeaconServiceConnect() {
    beaconManager.setRangeNotifier(new RangeNotifier() {
        @Override
        public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
            if (beacons.size() > 0) {
                final ArrayList<BeaconModel> list = new ArrayList<BeaconModel>();

                Iterator<Beacon> it = beacons.iterator();

                while (it.hasNext()) {
                    Beacon beacon = it.next();

                    BeaconModel model = new BeaconModel();

                    if (beacon.getServiceUuid() == 0xfeaa)
                    {
                        // This is Eddystone, which uses a service Uuid of 0xfeaa
                        Identifier eddystoneNamespaceId = beacon.getId1();
                        Identifier eddystoneInstanceId = beacon.getId2();
                    }
                    else
                    {

                    }


                    model.setBeaconName("Rssi: " + beacon.getRssi() + " Power: " + beacon.getTxPower());
                    model.setDistance("Dist: " + beacon.getDistance());

                    list.add(model);
                }

                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        CustomBeaconAdapter adapter = new CustomBeaconAdapter(list, MainActivity.this);
                        beaconList.setAdapter(adapter);
                    }
                });
            }
        }
    });

    try {
        beaconManager.startRangingBeaconsInRegion(new Region("myMonitoringUniqueId", null, null, null));
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}
 
开发者ID:sahir,项目名称:eddystone-beacon,代码行数:51,代码来源:MainActivity.java

示例15: setupBeaconManager

import org.altbeacon.beacon.RangeNotifier; //导入依赖的package包/类
private void setupBeaconManager() {
        mBeaconManager = BeaconManager.getInstanceForApplication(mFindMyTagView.get().getContext());
        mBeaconManager.getBeaconParsers().clear();
        mBeaconManager.getBeaconParsers().add(
                new BeaconParser().setBeaconLayout(MY_BEACON_LAYOUT)
        );
//        mBeaconManager.setMonitorNotifier(new MonitorNotifier() {
//            @Override
//            public void didEnterRegion(Region region) {
//                Log.d(TAG, "didEnterRegion: " + region.toString());
//                mFindMyTagView.get().onBeaconEnter(region.toString());
//            }
//
//            @Override
//            public void didExitRegion(Region region) {
//                Log.d(TAG, "didExitRegion: " + region.toString());
//                mFindMyTagView.get().onBeaconExit(region.toString());
//            }
//
//            @Override
//            public void didDetermineStateForRegion(int state, Region region) {
//                Log.d(TAG, "didDetermineStateForRegion: " + region.toString() + " state: " + state);
//                mFindMyTagView.get().onBeaconState(state, region.toString());
//            }
//        });

        mBeaconManager.setRangeNotifier(new RangeNotifier() {
            @Override
            public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
                if (mFindMyTagView.get() != null && beacons.size() > 0) {
                    Beacon beacon = beacons.iterator().next();
                    Log.i(TAG, "UUID: " + beacon.getBluetoothAddress() + " beacon: " + beacon.getBluetoothName() + " distance: " + beacon.getDistance() + " data: " + beacon.getDataFields());

                    String uid = beacon.getBluetoothAddress();
                    mFindMyTagView.get().onBeaconEnter(beacon);
                    if (TextUtils.isEmpty(mFliterUid) || !uid.equals(mFliterUid))
                        return;
                    mFindMyTagView.get().onBeaconDistance(uid, beacon.getBluetoothName(), beacon.getDistance(), beacon.getDataFields());
                }
            }
        });
        mBeaconManager.bind(this);
    }
 
开发者ID:legendmohe,项目名称:LEHomeMobile_android,代码行数:44,代码来源:FindMyTagPresenter.java


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