Guest User

Untitled

a guest
Dec 4th, 2016
97
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

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×