Skip to content

Commit

Permalink
explicitly bind to BeaconService even if starting in foreground for A…
Browse files Browse the repository at this point in the history
…ndroid o+
  • Loading branch information
davidgyoung committed Oct 5, 2018
1 parent ccb2071 commit 75f756f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/java/org/altbeacon/beacon/BeaconManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,13 @@ public class BeaconManager {
* Set to true if you want to show library debugging.
*
* @param debug True turn on all logs for this library to be printed out to logcat. False turns
* off all logging.
* @deprecated To be removed in a future release. Use
* off detailed logging..
*
* This is a convenience method that calls setLogger to a verbose logger and enables verbose
* logging. For more fine grained control, use:
* {@link org.altbeacon.beacon.logging.LogManager#setLogger(org.altbeacon.beacon.logging.Logger)}
* instead.
*/
@Deprecated
public static void setDebug(boolean debug) {
if (debug) {
LogManager.setLogger(Loggers.verboseLogger());
Expand Down Expand Up @@ -434,7 +435,9 @@ public void bind(@NonNull BeaconConsumer consumer) {
Intent intent = new Intent(consumer.getApplicationContext(), BeaconService.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
this.getForegroundServiceNotification() != null) {
LogManager.i(TAG, "Starting foreground beacon scanning service.");
mContext.startForegroundService(intent);
consumer.bindService(intent, newConsumerInfo.beaconServiceConnection, Context.BIND_AUTO_CREATE);
}
else {
consumer.bindService(intent, newConsumerInfo.beaconServiceConnection, Context.BIND_AUTO_CREATE);
Expand Down

2 comments on commit 75f756f

@rohand27
Copy link

@rohand27 rohand27 commented on 75f756f Oct 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for now. Would it make sense to move the bindService() call out of the IF block? To not repeat the same code on line 440 and 443.

@davidgyoung
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, good point!

Please sign in to comment.