Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1. BeaconScanner scanner = new BeaconScanner();
  2.         scanner.setListener(new BeaconScanner.OnBeaconDetectedListerner() {
  3.             long ignoreUntil = 0;
  4.             @Override
  5.             public void onBeaconDetected(BluetoothDevice device, BeaconInfo beaconInfo) {
  6.                     if (beaconInfo.getMajor() == 0 && beaconInfo.getMinor() == 1) {
  7.                         if (ignoreUntil > System.currentTimeMillis())
  8.                             return;
  9.  
  10.                     // play sound and show snack bar notification
  11.                     try {
  12.                         Toast toast = Toast.makeText(getApplicationContext(), "It works!", Toast.LENGTH_LONG);
  13.                         toast.show();
  14.                     } catch (Exception e) {
  15.                         e.printStackTrace();
  16.                     }
  17.  
  18.  
  19.                     // ignore any beacons for the next 3.5 seconds (as we send bursts in the bean)
  20.                     ignoreUntil = System.currentTimeMillis() + 3500;
  21.                 }
  22.             }
  23.         });
  24.         scanner.startScan();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement