Question

I am using radiusnetworks Android API for my IBeacon service. According to their docs, "When constructing a range, any or all of these fields may be set to null, which indicates that they are a wildcard and will match any value." However, when I create a region with null proximityUUID, I get a null pointer exception. Here is the stack:

Thread [<1> main] (Suspended (exception NullPointerException))  
<VM does not provide monitor information>   
RegionData(Region).hashCode() line: 140 
HashMap.containsKey(Object) line: 332   
IBeaconService.startRangingBeaconsInRegion(Region, Callback) line: 262  
IBeaconService$IncomingHandler.handleMessage(Message) line: 151 
IBeaconService$IncomingHandler(Handler).dispatchMessage(Message) line: 99   

This does not happen when I set the proximityUUID to a value. Have anybody used this library and tried to set proximity uuid to null?

Was it helpful?

Solution

While the ProximityUuid, major and minor in a Region may be null, you must provide some value for the "uniqueId" which is the first parameter to the constructor:

new Region("com.myappname.myregiondescriptor", null, null, null);

This works, but the following will give you the error you describe:

new Region(null, null, null, null);

That first parameter has nothing to do with the iBeacon identifiers. It is just used as a unique reference string for your app, so you can cancel ranging/monitoring at a later time by passing the IBeaconManager a region with the same uniqueId string. You can give it any value you want, but if you start monitoring or ranging on a second Region that has the same uniqueId value, it will replace that Region currently being monitored.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top