I am trying to do simple BLE Beacon monitoring using the provided sample app. I do not get any detections on a Samsung Galaxy A51.
According to the documentation, this is expected since i am using an empty scan filer. What I am struggling with is identifying how and where to apply these scan filters in the provided reference app, as it is using this code:
public void onCreate() {
super.onCreate();
BeaconManager beaconManager = org.altbeacon.beacon.BeaconManager.getInstanceForApplication(this);
beaconManager.getBeaconParsers().clear();
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
Notification.Builder builder = new Notification.Builder(this);
builder.setSmallIcon(R.drawable.ic_launcher);
builder.setContentTitle("Scanning for Beacons");
Intent intent = new Intent(this, MonitoringActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(
this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT
);
builder.setContentIntent(pendingIntent);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel("My Notification Channel ID",
"My Notification Name", NotificationManager.IMPORTANCE_DEFAULT);
channel.setDescription("My Notification Channel Description");
NotificationManager notificationManager = (NotificationManager) getSystemService(
Context.NOTIFICATION_SERVICE);
notificationManager.createNotificationChannel(channel);
builder.setChannelId(channel.getId());
}
beaconManager.enableForegroundServiceScanning(builder.build(), 456);
beaconManager.setEnableScheduledScanJobs(false);
beaconManager.setBackgroundBetweenScanPeriod(0);
beaconManager.setBackgroundScanPeriod(1100);
Log.d(TAG, "setting up background monitoring in app onCreate");
beaconManager.addMonitorNotifier(this);
for (Region region: beaconManager.getMonitoredRegions()) {
beaconManager.stopMonitoring(region);
}
beaconManager.startMonitoring(wildcardRegion);
}
There is no need to manually add a scan filter with the Android Beacon Library. The library adds filters automatically as needed for Samsung and other Android models. Per the documentation, the only time it needs help is if a non-standard beacon is being used that uses a custom manufacturer identifier. In this rare case the library needs to be told that custom manufacturer identifier for the automatic scan filter to work.
Since this is not what is causing the problem with detections something else must be. A few suggestions: