コード例 #1
0
 @Override
 public void onActivityResumed(Activity activity) {
   ++this.activeActivityCount;
   if (activity instanceof ScannerActivity) {
     beaconManager.setBackgroundMode(false);
     isScannerActivityResumed = true;
     // the scanner activity runs in foreground mode, fast scanning
     Timber.d("setForegroundMode");
   } else {
     // the app is still active but scan is backgrounded indefinitely
     beaconManager.setBackgroundBetweenScanPeriod(DELAY_FOREVER);
     isScannerActivityResumed = false;
     Timber.d("setBackgroundBetweenScanPeriod to %d ", DELAY_FOREVER);
     beaconManager.setBackgroundMode(true);
     Timber.d("setBackgroundMode");
   }
 }
コード例 #2
0
 @Override
 public void onActivityStopped(Activity activity) {
   if (activity instanceof ScannerActivity) {
     isScannerActivityResumed = false;
     scannerActivityDestroyedTimestamp = SystemClock.elapsedRealtime();
     long delayBetweenScans = getDelayBetweenScans();
     Timber.d("setBackgroundBetweenScanPeriod to %d ", delayBetweenScans);
     beaconManager.setBackgroundBetweenScanPeriod(delayBetweenScans);
     beaconManager.setBackgroundMode(true);
     Timber.d("setBackgroundMode");
   }
 }
コード例 #3
0
  @Override
  public void onBeaconServiceConnect() {
    // callback for when service connection is complete

    mBeaconManager.setBackgroundMode(true);
  }
コード例 #4
0
 public void pause() {
   this.monitoring = false;
   beaconManager.setBackgroundMode(true);
 }
コード例 #5
0
 public void resume() {
   this.monitoring = true;
   beaconManager.setBackgroundMode(false);
 }
コード例 #6
0
 /**
  * This method notifies the beacon service that the application is either moving to background
  * mode or foreground mode.
  *
  * @param backgroundMode true indicates the app is in the background
  */
 public void setBackgroundMode(boolean backgroundMode) {
   mBeaconManager.setBackgroundMode(backgroundMode);
 }