title: Background Scanning on Android 8+
body: <p>This question might be answered already but we would like to have a explicit confirmation.</p>
  
  <p>Currently we are using Proprietary beacons working as iBeacons in our business and we have reach the same problem most people is facing with background scanning we turn to our provider and they told us they were aware of the issue but have not been able to fix it to work on background scanning.</p>
  
  <p>We found <a href="http://www.davidgyoungtech.com/2017/08/07/beacon-detection-with-android-8" rel="nofollow noreferrer">David Young blog post</a> decide it to give a try how ever we found two blockers</p>
  
  <ol>
  <li><p>We are not able to get the beacon id from the data we got from the <code>ScanRecord</code> that we get from the scans results in our broadcast receiver (See the code below)</p></li>
  <li><p>We still not able to scan continuously in the background and periodic scans does not fit well on our use case.</p>
  
  <p>ArrayList scanResults = intent.getParcelableArrayListExtra(BluetoothLeScanner.EXTRA_LIST_SCAN_RESULT);
  ScanRecord record = scanResults.get(0).getScanRecord();</p></li>
  </ol>
  
  <p>We have a found a workaround for this issue by triggering the background scanning using <a href="https://developers.google.com/awareness/android-api/fence-api-overview" rel="nofollow noreferrer">Google Awareness Fence API</a> and starting the service in charge of scanning as a foreground service using <a href="https://developer.android.com/reference/android/content/Context#startForegroundService(android.content.Intent)" rel="nofollow noreferrer">startForegroundService</a> to start the service and then call <a href="https://developer.android.com/reference/android/app/Service#startForeground(int,%20android.app.Notification)" rel="nofollow noreferrer">startInForeground()</a> in the service instance to show a persisting notification indicating the action we are doing in the "background" this approach has worked well for our use case how ever it does it with the cost of showing that notification which does not create a good user experience.</p>
  
  <p>we would like to know if anybody has found a better solution for this issue because from google documentation it looks background scanning is something that definitely we will no be able to do anymore</p>