Estimote / Android-Fleet-Management-SDK

Estimote Fleet Management SDK for Android
https://developer.estimote.com
MIT License
835 stars 451 forks source link

Multiple region ranging fails at first time #235

Closed xcastoreo closed 6 years ago

xcastoreo commented 7 years ago

Hi again,

I'm trying to run multiple region ranging, but it seems that the first time I call the startRanging() methods, only the second call is working. So I stop the ranging, and when I call the two methods after, the two ranging are running. I verify this with the listeners.

My code:

public class MultipleRanging extends AppCompatActivity {
    private final static String UUID = "B9407F30-F5F8-466E-AFF9-25556B57FE6D";

    private BeaconManager beaconManager;

    private BeaconRegion beaconRegion1;
    private BeaconRegion beaconRegion2;

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

        this.beaconManager = new BeaconManager(this);

        this.beaconRegion1 = new BeaconRegion("region_1", java.util.UUID.fromString(UUID), 1, null);
        this.beaconRegion2 = new BeaconRegion("region_2", java.util.UUID.fromString(UUID), 2, null);

        this.beaconManager.setRangingListener(new BeaconManager.BeaconRangingListener {
            @Override
            public void onBeaconsDiscovered(BeaconRegion beaconRegion, List<Beacon> list) {
                Log.d("MultipleRanging", "Callback for region: " + beaconRegion.getIdentifier() + ".");
            }
        });
    }

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

        SystemRequirementsChecker.checkWithDefaultDialogs(this);

        this.beaconManager.connect(new BeaconManager.ServiceReadyCallback {
            beaconManager.startRanging(this.beaconRegion1);
            beaconManager.startRanging(this.beaconRegion2);
        });
    }

    @Override
    protected void onPause() {
        this.beaconManager.stopRanging(beaconRegion1);
        this.beaconManager.stopRanging(beaconRegion2);

        super.onPause();
    }

    @Override
    protected onDestroy() {
        this.beaconManager.disconnect();

        super.onDestroy();
    }
}
pawelDylag commented 7 years ago

Hello @xcastoreo

Thanks for reporting that - we'll take look at this problem in upcoming weeks! Cheers!

pawelDylag commented 7 years ago

Hey! I just wanted you to know that we are in the process of moving our SDK for Android to a completely new architecture. We won't be publishing any updates to our old (current master) SDK for a while.

But don't worry - there is an ALPHA version of our FRESH PROXIMITY SDK available now! It uses a completely new scanning mechanism and will work on new Android versions like a charm (6.0, 7.0, 8.0). We did a great job with renovating our ecosystem to cut off the old, messy code, full of hacks for Android KitKat an Jellybean. This is why working with BeaconManager was so frustrating by the way.

Plan for the next couple of weeks:

  1. ProximitySDK beta release - our own tag-based proximity. Use it to achieve the same behaviour as using iBeacon (monitoring/ranging). It is uses our own packets called Estimote Location and is backed-up by our own data-science. Read more here -> http://blog.estimote.com/post/166007374930/the-most-reliable-proximity-tech-now-with-a
  2. ScanningSDK beta release - a separate core library dedicated for raw scanning - it will handle the scanning on all android versions for you, battery efficiency, background/foreground, and will deliver raw stream of packet data (Such as iBeacon, Eddystone, EstimoteLocation, EstimoteTelemetry, etc).

I encourage you to try it out - there is a ready made app for you to show the possibilities of our completely new SDK -> https://github.com/Estimote/Android-SDK/tree/proximity-sdk Let us know what you think! I will keep you updated about the progress.