Search code examples
androiduuidaltbeacon

Android application: How to detect beacon without hardcoding the UUID of a specific beacon?


I am working on an Android application which tries to connect to nearby beacons.

Currently, this is how I am trying to detect a beacon. However, I want to detect multiple such beacons in the vicinity without specifically mentioning the UUID of it.

beaconManager.startMonitoringBeaconsInRegion(new Region("01122334-4556-6778-899a-abbccd2993a8", null, null, null));

How can I do this? I tried to look up multiple threads on stack overflow, but I couldn't really get any specific answer for this. It would be really helpful if I can get a documentation or a link to follow on this. I am sort of stuck on this stage of my project.


Solution

  • Just do this:

    beaconManager.startMonitoringBeaconsInRegion(new Region("any-identifier", null, null, null));
    

    The first parameter is just a reference string you can use top stop monitoring at a later time. Passing a region with the same reference string will stop monitoring for that region. Your code probably works as you want as-is, as any reference string value is allowed and has no affect on the beacons detected.