Skip to content

Commit

Permalink
Don't crash app if we fall behind on scans. Log a warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgyoung committed Apr 3, 2015
1 parent 4dd1d97 commit 53ea3bb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/org/altbeacon/beacon/service/BeaconService.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.RejectedExecutionException;

/**
* @author dyoung
Expand Down Expand Up @@ -297,8 +298,13 @@ public void setScanPeriods(long scanPeriod, long betweenScanPeriod, boolean back
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) {
new ScanProcessor().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
new ScanData(device, rssi, scanRecord));
try {
new ScanProcessor().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
new ScanData(device, rssi, scanRecord));
}
catch (RejectedExecutionException e) {
Log.w(TAG, "Ignoring scan result because we cannot keep up.", e);
}
}

@Override
Expand Down

0 comments on commit 53ea3bb

Please sign in to comment.