SHARE
TWEET

Untitled

a guest Dec 4th, 2016 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top