title: Multiple Beacon Consumer and beacon is not detecting using AltBeacon
body: <p>I am using altbeacon library in one of my android projects. In that project BeaconConsumer is already implemented in one of the activities. When I try to implement beacon detection in my part of the code beacon is not detecting.</p>
  <p>But when i remove the BeaconConsumer code from the previously written code, then my code works and detects beacon.</p>
  <p>This is the log when the beacon is not detecting. Why are there multiple consumers and is it the problem? If so, how can I remove multiple consumers.</p>
  <pre><code> I/System.out: ---------onBeaconServiceConnect
   D/BeaconParser: Parsing beacon layout: m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25
   D/BeaconParser: Parsing beacon layout: x,s:0-1=feaa,m:2-2=20,d:3-3,d:4-5,d:6-7,d:8-11,d:12-15
   D/BeaconParser: Parsing beacon layout: s:0-1=feaa,m:2-2=00,p:3-3:-41,i:4-13,i:14-19
   D/BeaconParser: Parsing beacon layout: s:0-1=feaa,m:2-2=10,p:3-3:-41,i:4-20v
   D/BeaconParser: Parsing beacon layout: m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24
   D/BeaconLocalBroadcastProcessor: Register calls: global=6 instance=6
   D/BeaconLocalBroadcastProcessor: Register calls: global=7 instance=7
   D/BeaconManager: consumer count is now: 2
   D/BeaconManager: This consumer is not bound.  Binding now: MainActivity@11b9235
   D/BeaconManager: Not starting beacon scanning service. Using scheduled jobs
   D/BeaconLocalBroadcastProcessor: Register calls: global=8 instance=8
   D/BeaconManager: consumer count is now: 3
   D/BeaconManager: Unbinding
   D/BeaconManager: Not unbinding from scanning service as we are using scan jobs.
   D/BeaconManager: Before unbind, consumer count is 3
   D/BeaconManager: After unbind, consumer count is 2
  </code></pre>
  <p>This is the class i am using</p>
  <pre><code>class BeaconsDataSource(private val context: Context) : BeaconConsumer, RangeNotifier,MonitorNotifier {
  
      private val beaconManager: BeaconManager =
              BeaconManager.getInstanceForApplication(context)
  
      private val region = Region(&quot;myRegion&quot;, null, null, null)
  
      private lateinit var data: Step
      private var listener: ((Step) -&gt; Unit)? = null
      override fun getApplicationContext(): Context = context
  
      override fun unbindService(p0: ServiceConnection?) {
          applicationContext.unbindService(p0!!)
      }
  
      override fun bindService(p0: Intent?, p1: ServiceConnection?, p2: Int): Boolean {
          
          return applicationContext.bindService(p0, p1!!, p2)
      }
  
      override fun onBeaconServiceConnect() {
          BeaconManager.setDebug(true)
          beaconManager.beaconParsers
                  .add(BeaconParser().setBeaconLayout(&quot;m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25&quot;))
          beaconManager.beaconParsers
                  .add(BeaconParser().setBeaconLayout(&quot;x,s:0-1=feaa,m:2-2=20,d:3-3,d:4-5,d:6-7,d:8-11,d:12-15&quot;))
          beaconManager.beaconParsers
                  .add(BeaconParser().setBeaconLayout(&quot;s:0-1=feaa,m:2-2=00,p:3-3:-41,i:4-13,i:14-19&quot;))
          beaconManager.beaconParsers.add(BeaconParser().setBeaconLayout(&quot;s:0-1=feaa,m:2-2=10,p:3-3:-41,i:4-20v&quot;))
          beaconManager.beaconParsers
                  .add(BeaconParser().setBeaconLayout(&quot;m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24&quot;))
  
  
          beaconManager.removeAllMonitorNotifiers()
          beaconManager.removeAllRangeNotifiers()
  
          beaconManager.addMonitorNotifier(this)
          beaconManager.addRangeNotifier(this)
  
          try {
              beaconManager.startMonitoringBeaconsInRegion(region)
              beaconManager.startRangingBeaconsInRegion(region)
          } catch (e: RemoteException) {
              e.printStackTrace()
          }
  
      }
  
      override fun didRangeBeaconsInRegion(p0: MutableCollection&lt;Beacon&gt;, p1: Region?) {
        
              data = Step.ENTER_NUMBER
              notifyListeners()
  
      }
  
      private fun notifyListeners() {
          listener?.invoke(data)
      }
  
  
      fun requestBeaconsUpdate(listener: (Step) -&gt; Unit) {
          this.listener = listener
          beaconManager.bind(this)
      }
  
      fun stopBeaconsUpdate() {       
          beaconManager.unbind(this)
      }
  
      override fun didDetermineStateForRegion(p0: Int, p1: Region?) {
          val msg = &quot;---------did determine state for region $p0&quot;
          Log.d(&quot;TAG&quot;, msg)
      }
  
  
      override fun didEnterRegion(p0: Region?) {
          val msg = &quot;-----------did enter region&quot;
          val zone = p0.toString()
          Log.d(&quot;TAG&quot;, &quot;----------Enter in region&quot;)
          val text = &quot;Enter in $zone&quot;
          Log.d(&quot;TAG&quot;, msg)
      }
  
      override fun didExitRegion(p0: Region?) {
          val msg = &quot;------------did exit region&quot;
          Log.d(&quot;TAG&quot;, msg)
      }
  
  }
  </code></pre>
  <p>This is my livedata class which i am calling from viewmodel</p>
  <pre><code>class BeaconsLiveData() : LiveData&lt;Step&gt;() {
  
      private val beaconDataSource = BeaconsDataSource(App.getAppContext())
  
      private val listener = { data: Step -&gt;
          value = data
        
      }
  
      override fun onActive() {
          super.onActive()
          beaconDataSource.requestBeaconsUpdate(listener)
      }
  
      override fun onInactive() {
          super.onInactive()
          beaconDataSource.stopBeaconsUpdate()
      }
  } 
  </code></pre>