2017-10-12 89 views
0

注意: 我查了多個設備依然沒有起色,我做了我的信標頻率到2000MS,但仍面臨這個問題上didRangeBeaconsInRegion幾秒鐘後,我的信中消失,但我接近我的燈塔

我面對一個問題信標檢測是穩定的幾秒鐘,但之後,它消失,然後它檢測到信標。我對這一個建議和代碼示例感謝!

代碼

this.beaconManager = BeaconManager.getInstanceForApplication(this); 
    beaconManager.setForegroundScanPeriod(500); 
    beaconManager.setForegroundBetweenScanPeriod(500); 
    enableBackgroundMode(true); 
    beaconManager.setAndroidLScanningDisabled(true); 
    this.beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24")); 
    this.beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout(EDDYSTONE_UID_LAYOUT)); 
    this.beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout(EDDYSTONE_URL_LAYOUT)); 
    this.beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout(EDDYSTONE_TLM_LAYOUT)); 
    this.beaconManager.setDebug(true); 
    this.beaconManager.bind(this); 




    this.beaconManager.addRangeNotifier(new RangeNotifier() { 
     @Override 
     public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) { 
      Log.e(TAG, "beacons size=>" + beacons.size()); 

      if (beacons.size() > 0) { 
       //my code 
      } 
    } 
}); 

logcat的:

10-12 12:33:48.381 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor} 
10-12 12:33:49.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor} 
10-12 12:33:50.356 12357-12881/com.mypackageName.android D/RangeState: adding id1: 87f8acb5-9ad0-29a7-204c-f080e2b55c0d id2: 10 id3: 1 to existing range for: [email protected] 
10-12 12:33:50.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor} 
10-12 12:33:51.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor} 
10-12 12:33:52.381 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor} 
10-12 12:33:52.391 12357-12880/com.mypackageName.android D/RangeState: adding id1: 87f8acb5-9ad0-29a7-204c-f080e2b55c0d id2: 10 id3: 1 to existing range for: [email protected] 
10-12 12:33:53.381 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor} 
10-12 12:33:54.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor} 
10-12 12:33:54.396 12357-12880/com.mypackageName.android D/RangeState: adding id1: 87f8acb5-9ad0-29a7-204c-f080e2b55c0d id2: 10 id3: 1 to existing range for: [email protected] 
10-12 12:33:55.381 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor} 
10-12 12:33:56.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor} 
10-12 12:33:57.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor} 
10-12 12:33:58.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor} 
10-12 12:33:59.381 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor} 
10-12 12:34:00.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor} 
10-12 12:34:01.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor} 
10-12 12:34:02.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor} 

回答

1

嘗試刪除線:(使用默認設置)

beaconManager.setForegroundScanPeriod(500); 
beaconManager.setForegroundBetweenScanPeriod(500); 

沒有這些行,圖書館將掃描不斷地在前景。隨着這些線路的出現,它一次只能掃描半秒,因此它很可能會錯過您的烽火臺傳輸並導致檢測中的輟學。

+0

我會嘗試它的前景。如何進行背景掃描? – prasanthMurugan

+1

對於後臺掃描,建議使用BackgroundPowerSaver類。它會在後臺和前臺模式之間自動切換你的應用。默認情況下,背景掃描每5分鐘運行10秒(Android 8+每15分鐘運行一次),並且低功耗掃描在後臺不斷運行在Android 5+上,直到首次發現信標爲止。這是使用BackgroundPowerSaver時的所有默認行爲。 – davidgyoung

+0

好的非常感謝。愛你的產品和你給它支持的方式:-) – prasanthMurugan

相關問題