Beacons not getting detected properly in Andriod App

Hi,

I am trying to detect the beacons in an andriod app, unfortunately it is not getting detect every time when the App runs.
I have 3 beacons, trying to find in my app but only one out of any of the 3 beacon gets detected at once.

I have used the below function to detect the beacons.
public void onBeaconsDiscovered(BeaconRegion region,final List beacons) {
** if(beacons.size() > 0) {**
** }**
** }**

the size of the beacons is 0 most of the times, and at times only one beacon(randomly any 1 out of 3 ) gets detected.
I am using Android studio 2.3.3.
Estimote SDK : com.estimote:sdk:1.0.3@aar
Minimum SDK : API 23 (android 6)

i have uploaded the source could as well, can anyone please guide is the resolve the solution. The App should detect all the beacons at once and everytime the app runs. I am testing the App on OnePluse 3 with Android 7.1.1.

MainActivity.txt (3.2 KB)

Hi @varun.kmani,

First, have you verified that you can detect your 3 beacons with the Estimote app’?
If yes, it must be that issue: ranging and monitoring are not working since the 1.0.2 Android SDK version.
Try your app’ with this line in the plugin.xml file:

<framework src="com.estimote:sdk:1.0.1@aar">

And notify us if it works :slight_smile:

Hi Ximun,

Appreciate the response :).

Yes the beacons are getting detected in Estimote App .

I have changed the dependencies to { compile ‘com.estimote:sdk:1.0.1@aar’} in build.gradle file and clicked on “Sync Project with Gradle Files” and ran the app and still the same issue persist.
Couldnt find plugin.xml in my project. Can you let me know where its located.

I was working on a Cordova plugin with Estimote so I had a plugin.xml, sorry…
Arf I really don’t know what it can be, my ranging and monitoring activities work well here :frowning:

I would put theStartRanging() method call in the onResume() method, after checking the system requirements, because an activity creation does onCreate() -> onStart() -> onResume() (see here).


[details=Simple code to watch if something can help you:]```java
class MyActivity {
private BeaconManager mBeaconManager;
private BeaconRegion mBeaconRegion;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // New BeaconManager instance.
    mBeaconManager = new BeaconManager(this);
    // Setting up the listener.
    mBeaconManager.setRangingListener(
            new BeaconManager.BeaconRangingListener() {
        @Override
        public void onBeaconsDiscovered(BeaconRegion region,
                List<Beacon> list) {
            // Handle here the discovered beacons list of the region.
        }
    });

    // New BeaconRegion instance to customize.
    mBeaconRegion = new BeaconRegion(<identifier>,
            <proximityUUID>, <major>, <minor>);
}

@Override
protected void onResume() {
    super.onResume();

    // Checks automatically the permissions.
    SystemRequirementsChecker.checkWithDefaultDialogs(this);

    // Starts ranging after being connected to the BeaconService.
    mBeaconManager.connect(new BeaconManager.ServiceReadyCallback() {
        @Override
        public void onServiceReady() {
            mBeaconManager.startRanging(mBeaconRegion);
        }
    });
}

@Override
protected void onPause() {
    // Ranging is on foreground only, so stop it when activity is paused.
    mBeaconManger.stopRanging(mBeaconRegion);

    super.onPause();
}

@Override
protected void onDestroy() {
    // Disconnect from BeaconService when not used.
    mBeaconManager.disconnect();

    super.onStop();
}

}

Also, don’t name your method StartRanging() but startRanging() because Java class names begin with a capital letter and lowercase letters for Java method and attributes names.