Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BeaconScanner scanner = new BeaconScanner();
- scanner.setListener(new BeaconScanner.OnBeaconDetectedListerner() {
- long ignoreUntil = 0;
- @Override
- public void onBeaconDetected(BluetoothDevice device, BeaconInfo beaconInfo) {
- if (beaconInfo.getMajor() == 0 && beaconInfo.getMinor() == 1) {
- if (ignoreUntil > System.currentTimeMillis())
- return;
- // play sound and show snack bar notification
- try {
- Toast toast = Toast.makeText(getApplicationContext(), "It works!", Toast.LENGTH_LONG);
- toast.show();
- } catch (Exception e) {
- e.printStackTrace();
- }
- // ignore any beacons for the next 3.5 seconds (as we send bursts in the bean)
- ignoreUntil = System.currentTimeMillis() + 3500;
- }
- }
- });
- scanner.startScan();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement