Don't cal startForegroundService if we have already bound to the service.  Doing so causes a crash.
@@ -429,9 +429,15 @@ public class BeaconManager {
Intent intent = new Intent(consumer.getApplicationContext(), BeaconService.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
this.getForegroundServiceNotification() != null) {
+ if (isAnyConsumerBound()) {
+ LogManager.i(TAG, "Not starting foreground beacon scanning" +
+ " service. A consumer is already bound, so it should be started");
+ }
+ else {
LogManager.i(TAG, "Starting foreground beacon scanning service.");
mContext.startForegroundService(intent);
}
+ }
else {
}
consumer.bindService(intent, newConsumerInfo.beaconServiceConnection, Context.BIND_AUTO_CREATE);
