title: How to detect multiple beacons using Altbeacon android library?
body: <p>I am using the AltBeacon sample app on my android device - the sample app provided by altbeacon.org is here: <a href="https://github.com/AltBeacon/android-beacon-library-reference" rel="noreferrer">https://github.com/AltBeacon/android-beacon-library-reference</a></p>
  
  <p>However, the app when launched is detecting and displaying only one beacon. I have about 5 beacons near my Android device. How do I detect all the beacons?</p>
  
  <p>In RangingActivity.java, I noticed this method that is being called when a beacon comes in sight:</p>
  
  <pre><code>public void onBeaconServiceConnect() {
      beaconManager.setRangeNotifier(new RangeNotifier() {
      @Override 
      public void didRangeBeaconsInRegion(Collection&lt;Beacon&gt; beacons, Region region) {
          if (beacons.size() &gt; 0) {
              EditText editText = (EditText) RangingActivity.this.findViewById(R.id.rangingText);                    
                      Beacon firstBeacon = beacons.iterator().next();
                      logToDisplay("The first beacon " + firstBeacon.toString() + " is about " + firstBeacon.getDistance() + " meters away.");
              }
          }
      }
  </code></pre>
  
  <p>I modified the iterator to read from the collection in a while loop as follows:</p>
  
  <pre><code>     Beacon firstBeacon;
       while(beacons.iterator().hasNext()){
                  firstBeacon = beacons.iterator().next();
                  logToDisplay("The first beacon " + firstBeacon.toString() + " is about " + firstBeacon.getDistance() + " meters away.");
              }
  </code></pre>
  
  <p>However, the app crashes with this modification. </p>
  
  <p>My questions: </p>
  
  <p>(1) How can I display all beacons that are near my Android device?</p>
  
  <p>(2) How can I detect beacons that go out of region?</p>