Empty list of discovered beacons

I don’t know why the toast notifications always prints 0 even thow there are more than 5 beacons in less than 2 meters.

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        beaconManager = new BeaconManager(this);
        region = new BeaconRegion("ranged region", null /*UUID.fromString("B9407F30-F5F8-466E-AFF9-25556B57FE6D")*/, null, null);


        beaconManager.setForegroundScanPeriod(500, 1000);
        beaconManager.setRangingListener(new BeaconManager.BeaconRangingListener() {
            @Override
            public void onBeaconsDiscovered(BeaconRegion region, List<Beacon> list) {
                Toast.makeText(getApplicationContext(), ((String)(""+list.size())), Toast.LENGTH_LONG).show();
              }
        });
    }

Have you tried longer scan periods? 500 ms can be a bit too short for some less responsive Android devices.

FYI, since it seems like you’re using the github.com/estimote/android-sdk. The proximity-detection (enter/exit monitoring, ranging) APIs in that SDK are deprecated—they will no longer receive updates/improvements, unless it’s critical bug or security fixes. We recommend switching to the github.com/estimote/android-proximity-sdk. Integration tutorial is here: https://developer.estimote.com/proximity/android-tutorial/

I’ve already followed the tutorial but it doesn’t work…

Marco Rocchi

Hmm, what was the problem?

The function onBeaconsDiscovered always recive an empty list, even thow near my phone there are 4 or 5 beacons.

Where do you call beaconManager.connect() and 'beaconManager.startRanging(…)` ? I don’t see it in code snippet.
Do you have something like this in your code?

 beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
        @Override
        public void onServiceReady() {
            beaconManager.startRanging(region);
      }
    });

startRanging should be called after onServiceReady is invoked.

Here is the complete code with some adjustment and the same issue… as you can see I am calling the beaconManager.connect() function.

public class MainActivity extends AppCompatActivity {

    private BeaconManager beaconManager;
    private BeaconRegion region;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        beaconManager=new BeaconManager(getApplicationContext());
        beaconManager.setRangingListener(new BeaconManager.BeaconRangingListener() {
            @Override
            public void onBeaconsDiscovered(BeaconRegion beaconRegion, List<Beacon> beacons) {
                Toast.makeText(getApplicationContext(), "ranging listener   "+beacons.size(), Toast.LENGTH_LONG).show();

            }
        });
        region=new BeaconRegion("regione", UUID.fromString("7F07FEFA-34CE-50C6-D630-6ADFF41C0ADD"), 1, 1);
        beaconManager.setMonitoringListener(new BeaconManager.BeaconMonitoringListener() {
            @Override
            public void onEnteredRegion(BeaconRegion beaconRegion, List<Beacon> beacons) {
                Toast.makeText(getApplicationContext(), "entrato   "+beacons.size(), Toast.LENGTH_LONG).show();
            }

            @Override
            public void onExitedRegion(BeaconRegion beaconRegion)
            {

            }
        });
        beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
            public void onServiceReady() {
                beaconManager.startRanging(region);
            }
        });

        beaconManager.startRanging(region);


    }

    protected void onResume()
    {
        super.onResume();
        SystemRequirementsChecker.checkWithDefaultDialogs(this);
    }
  }

What I need is to have a list of beacons in range and detect their distance

I run you code on Xiaomi Mi6 (Android 6.0.1) and it scans without a problem. I only modified

region=new BeaconRegion("regione", UUID.fromString("7F07FEFA-34CE-50C6-D630-6ADFF41C0ADD"), 1, 1);

to

 region=new BeaconRegion("regione", null, null, null);

so I can scan for all iBeacons.
Can you check if it helps? Also knowing your phone model, its Android version and Estimote SDK version may help.

LG K8 with Android 6.0, Estimote SDK 1.4.1 and still doesn’t working.

Capture%20_2018-05-07-17-48-08%5B1%5D

The beacon is broadcasting Estimote Monitoring, Estimote Location, Estimote Telemetry and IBeacon packets

Can you share some logcat logs and btsnoop logs? Maybe there is an error message telling why phone is not starting scanning.

I’m having some problems with the logcat but I’ve tried to run the ap on another Android 6.0 device and it isn’t working.

I’ll share the logcat as soon as I can.

Can you use nRF Connect and scan for those beacons? This way we can eliminate phone as the potential source of this problem.

Capture%20_2018-05-08-15-58-30%5B1%5DCapture%20_2018-05-08-15-58-36%5B1%5D

I have a dev kit 10cm away from my phone

Here is using the Estimote app

Capture%20_2018-05-08-16-21-32%5B1%5D

Estimote app uses Proximity SDK for scanning. Maybe that is the reason it is working. Android SDK 1.4.1 is deprecated for scanning.
I don’t see also EstimoteSDK.initialize(...) in your code. Do you have it in your Application class?
You may try to use those flags before BeaconManager initialisation:

    Flags.DISABLE_BATCH_SCANNING.set(true);
    Flags.DISABLE_HARDWARE_FILTERING.set(true);
1 Like

Now it finds the list of beacons but all beacons in the list are null

But what actually helped? 'EstimoteSDK.initialize` or one of the flags? Can you check that? Does the logcat show any errors or strange messages?

The flags.
EstimoteSDK.initialize was already in the app in another activity.

Hello
Have you found an answer? I used the flags like explained above but it didnt help. OnBeaconsDiscovered method is called by the lt is empty/ it drives me crazy. please help.