title: Alt Beacon Android unstable
body: <p>I am building an android application based on the Alt Beacon. I should preface this with the fact that my test device is a Digiland (P-O-S) tablet running android 4.4. </p>
  
  <p>I am using the Radius Networks USB beacon and their Alt Beacon library found here: <a href="https://github.com/AltBeacon/android-beacon-library" rel="nofollow">https://github.com/AltBeacon/android-beacon-library</a></p>
  
  <p>In both my own application and in the reference application provided with the library I am seeing significant instability / extremely slow detection times for the beacon. For example, you can see the  reference application's log below. The tablet is sitting no more than 1/2 meter away from the beacon the whole time.</p>
  
  <p>Has anyone seen this behavior before? Am I doing something wrong? The broadcast rate on the beacon appears to be set to 10Hz and the power seems to be set to maximum. Should I get a different device and try it on that? I saw some other posts suggested turning off the wifi which I did, and this log is from a trial with the wifi off. </p>
  
  <p>One thing I should note is that I have increased the scan frequency with the following block of code in the application subclass:</p>
  
  <pre><code>beaconManager.setBackgroundBetweenScanPeriod(9000l);
  beaconManager.setBackgroundScanPeriod(1000l);
  beaconManager.setForegroundBetweenScanPeriod(9000l);
  beaconManager.setForegroundScanPeriod(1000l);
  try{
      beaconManager.updateScanPeriods();
  }catch (RemoteException e){
      e.printStackTrace();
  }
  </code></pre>
  
  <p>I am not sure if this is done improperly, but when I remove it, I still see the same behavior described in the log below, just over a somewhat longer period of time. </p>
  
  <p>Any advice people have would be much appreciated since I feel like I am spinning my wheels on this!</p>
  
  <pre><code>07-01 15:23:59.005  10771-10771/org.altbeacon.beaconreference D/ReferenceApplication﹕ setting up background monitoring for beacons and power saving
  07-01 15:23:59.655  10771-10816/org.altbeacon.beaconreference D/ReferenceApplication﹕ did enter region.
  07-01 15:23:59.655  10771-10816/org.altbeacon.beaconreference D/ReferenceApplication﹕ auto launching MainActivity
  07-01 15:24:20.154  10771-11297/org.altbeacon.beaconreference D/ReferenceApplication﹕ did exit region
  07-01 15:24:39.174  10771-11486/org.altbeacon.beaconreference D/ReferenceApplication﹕ did enter region.
  07-01 15:25:00.132  10771-11647/org.altbeacon.beaconreference D/ReferenceApplication﹕ did exit region
  07-01 15:25:09.472  10771-11730/org.altbeacon.beaconreference D/ReferenceApplication﹕ did enter region.
  07-01 15:25:30.123  10771-11871/org.altbeacon.beaconreference D/ReferenceApplication﹕ did exit region
  07-01 15:25:39.173  10771-11954/org.altbeacon.beaconreference D/ReferenceApplication﹕ did enter region.
  07-01 15:26:00.065  10771-12070/org.altbeacon.beaconreference D/ReferenceApplication﹕ did exit region
  07-01 15:26:29.099  10771-12083/org.altbeacon.beaconreference D/ReferenceApplication﹕ did enter region.
  07-01 15:26:29.100  10771-12083/org.altbeacon.beaconreference D/ReferenceApplication﹕ Sending notification.
  07-01 15:26:40.112  10771-12096/org.altbeacon.beaconreference D/ReferenceApplication﹕ did exit region
  07-01 15:27:19.120  10771-12127/org.altbeacon.beaconreference D/ReferenceApplication﹕ did enter region.
  07-01 15:27:19.120  10771-12127/org.altbeacon.beaconreference D/ReferenceApplication﹕ Sending notification.
  07-01 15:27:40.041  10771-12208/org.altbeacon.beaconreference D/ReferenceApplication﹕ did exit region
  07-01 15:27:59.110  10771-12786/org.altbeacon.beaconreference D/ReferenceApplication﹕ did enter region.
  07-01 15:28:30.144  10771-13052/org.altbeacon.beaconreference D/ReferenceApplication﹕ did exit region
  07-01 15:28:39.202  10771-13131/org.altbeacon.beaconreference D/ReferenceApplication﹕ did enter region.
  07-01 15:28:50.133  10771-13226/org.altbeacon.beaconreference D/ReferenceApplication﹕ did exit region
  07-01 15:29:09.125  10771-13375/org.altbeacon.beaconreference D/ReferenceApplication﹕ did enter region.
  07-01 15:29:30.119  10771-13452/org.altbeacon.beaconreference D/ReferenceApplication﹕ did exit region
  07-01 15:29:49.144  10771-13473/org.altbeacon.beaconreference D/ReferenceApplication﹕ did enter region.
  07-01 15:30:00.060  10771-13510/org.altbeacon.beaconreference D/ReferenceApplication﹕ did exit region
  07-01 15:30:19.134  10771-13552/org.altbeacon.beaconreference D/ReferenceApplication﹕ did enter region.
  07-01 15:30:19.135  10771-13552/org.altbeacon.beaconreference D/ReferenceApplication﹕ Sending notification.
  07-01 15:30:30.096  10771-13560/org.altbeacon.beaconreference D/ReferenceApplication﹕ did exit region
  07-01 15:31:09.124  10771-13575/org.altbeacon.beaconreference D/ReferenceApplication﹕ did enter region.
  07-01 15:31:09.125  10771-13575/org.altbeacon.beaconreference D/ReferenceApplication﹕ Sending notification.
  07-01 15:31:20.110  10771-13576/org.altbeacon.beaconreference D/ReferenceApplication﹕ did exit region
  07-01 15:31:29.101  10771-13578/org.altbeacon.beaconreference D/ReferenceApplication﹕ did enter region.
  07-01 15:31:29.101  10771-13578/org.altbeacon.beaconreference D/ReferenceApplication﹕ Sending notification.
  07-01 15:32:40.101  10771-13647/org.altbeacon.beaconreference D/ReferenceApplication﹕ did exit region
  07-01 15:32:59.131  10771-13651/org.altbeacon.beaconreference D/ReferenceApplication﹕ did enter region.
  </code></pre>
  
  <p>One more interesting thing to note is that when I do a filter for onScanResult in the logs I see this:</p>
  
  <pre><code>07-01 15:45:49.074  10771-10839/org.altbeacon.beaconreference D/BluetoothAdapter﹕ onScanResult() - Device=24:4B:03:2E:00:D9 RSSI=-91
  07-01 15:45:49.117    1425-1495/? D/BtGatt.GattService﹕ onScanResult() - address=00:07:80:1E:7E:B7, rssi=-56
  07-01 15:45:49.120  10771-10784/org.altbeacon.beaconreference D/BluetoothAdapter﹕ onScanResult() - Device=00:07:80:1E:7E:B7 RSSI=-56
  07-01 15:45:49.365    1425-1495/? D/BtGatt.GattService﹕ onScanResult() - address=62:44:C6:64:4D:A5, rssi=-76
  07-01 15:45:49.368  10771-10783/org.altbeacon.beaconreference D/BluetoothAdapter﹕ onScanResult() - Device=62:44:C6:64:4D:A5 RSSI=-76
  07-01 15:45:59.082    1425-1495/? D/BtGatt.GattService﹕ onScanResult() - address=62:44:C6:64:4D:A5, rssi=-77
  07-01 15:45:59.084  10771-10784/org.altbeacon.beaconreference D/BluetoothAdapter﹕ onScanResult() - Device=62:44:C6:64:4D:A5 RSSI=-77
  07-01 15:45:59.130    1425-1495/? D/BtGatt.GattService﹕ onScanResult() - address=00:07:80:1E:7E:B7, rssi=-59
  07-01 15:45:59.133  10771-10783/org.altbeacon.beaconreference D/BluetoothAdapter﹕ onScanResult() - Device=00:07:80:1E:7E:B7 RSSI=-59
  07-01 15:45:59.140    1425-1495/? D/BtGatt.GattService﹕ onScanResult() - address=24:4B:03:2E:00:D9, rssi=-76
  07-01 15:45:59.141  10771-10839/org.altbeacon.beaconreference D/BluetoothAdapter﹕ onScanResult() - Device=24:4B:03:2E:00:D9 RSSI=-76
  07-01 15:46:09.115    1425-1495/? D/BtGatt.GattService﹕ onScanResult() - address=00:07:80:1E:7E:B7, rssi=-58
  07-01 15:46:09.117  10771-10783/org.altbeacon.beaconreference D/BluetoothAdapter﹕ onScanResult() - Device=00:07:80:1E:7E:B7 RSSI=-58
  07-01 15:46:09.124    1425-1495/? D/BtGatt.GattService﹕ onScanResult() - address=24:4B:03:2E:00:D9, rssi=-86
  07-01 15:46:09.126  10771-10839/org.altbeacon.beaconreference D/BluetoothAdapter﹕ onScanResult() - Device=24:4B:03:2E:00:D9 RSSI=-86
  07-01 15:46:09.135    1425-1495/? D/BtGatt.GattService﹕ onScanResult() - address=62:44:C6:64:4D:A5, rssi=-76
  07-01 15:46:09.139  10771-10784/org.altbeacon.beaconreference D/BluetoothAdapter﹕ onScanResult() - Device=62:44:C6:64:4D:A5 RSSI=-76
  07-01 15:46:19.060    1425-1495/? D/BtGatt.GattService﹕ onScanResult() - address=24:4B:03:2E:00:D9, rssi=-91
  07-01 15:46:19.062  10771-10839/org.altbeacon.beaconreference D/BluetoothAdapter﹕ onScanResult() - Device=24:4B:03:2E:00:D9 RSSI=-91
  07-01 15:46:19.092    1425-1495/? D/BtGatt.GattService﹕ onScanResult() - address=00:07:80:1E:7E:B7, rssi=-64
  </code></pre>
  
  <p>The 00:07:80 device is my beacon, but I have no idea whatsoever when the 24:4B:03 device is. Does anyone know how I can get more data about this device? Is it possible that it is interfering with my actual signal? I have tried using both</p>
  
  <pre><code>Region region = new Region("backgroundRegion",
                  Identifier.parse("2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6"), null, null);
  </code></pre>
  
  <p>and </p>
  
  <pre><code>Region region = new Region("backgroundRegion",null, null, null); 
  </code></pre>
  
  <p>Unfortunately I get this random fluctuation with both variations. </p>
  
  <p>UPDATE:</p>
  
  <p>I also ran this with the beaconManager.setDebug(true) flag activated. Here is the <a href="http://gist.github.com/akhalsa/2dec67616e75ebed55ee" rel="nofollow">resulting log</a></p>
  
  <p>UPDATE 2:</p>
  
  <p>I switched my beacon to only broadcast for iBeacon and the problem seemed to go away for about 10 minutes. Unfortunately the problem quickly returned. Looking through the logs, what I am seeing is quite different now. The logs can be seen <a href="https://gist.github.com/akhalsa/4bcdf1f6b6ad2e12b626" rel="nofollow">here</a>. My assumption is that the problem is with this line: </p>
  
  <pre><code>07-01 21:46:31.035    2499-2499/com.avtar.truckkeeper D/CycledLeScanner﹕ cancel wakeup alarm: PendingIntent{41f32070: android.os.BinderProxy@41d8f750}
  </code></pre>
  
  <p>Any thoughts/help would be much appreciated!</p>