I’m testing Galaxy S3 Mini with Android CyanogenMod Marshmallow build.
Estimote Android SDK : 0.10.5 version.
I set up my region allocating NULL to MinorID … i.e. Monitoring only for MajorID as region.
By setting the MinorID parameter to NULL I get NullPointerException.
My Code:
beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
@Override
public void onServiceReady() {
beaconManager.startMonitoring(new Region(
MONITOR_REGION_ID,
UUID.fromString(ESTIMOTE_STANDARD_UUID),
DEMO_STORE_CHAIN, null));
}
});
The Log:
java.lang.NullPointerException: Attempt to invoke virtual method ‘int java.lang.Integer.intValue()’ on a null object reference
at com.softserveapps.myAPP.MainActivity$2.onEnteredRegion(MainActivity.java:120)
at com.estimote.sdk.BeaconManager$IncomingHandler.handleMessage(BeaconManager.java:846)
Please advise.
Looks like a bug in our SDK, we’ll look into that. Thanks for the report!
Oh, actually, it looks like it’s not a bug in our SDK at all!
Instead, it seems that you’re trying to call intValue()
on a null minor
yourself, in the 120th line in your MainActivity.java file.
Hi Heypiotr
Dziękuję Ci! Got it !! … (int) instead of (Integer)
KR
1 Like
Heypiotr
I’m still getting strange results with 0.10.5 Region Monitor.
Here is my Monitor code:
beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
@Override
public void onServiceReady() {
beaconManager.startMonitoring(new Region(
MONITOR_REGION_ID,
UUID.fromString(ESTIMOTE_STANDARD_UUID),
DEMO_STORE_CHAIN, null));
}
});
public void onEnteredRegion(Region region, List<Beacon> list) {
Log.i(TAGi, "MAJOR ID ..." + region.getMajor()+"\n"
+ "MINOR ID ... " + region.getMinor()+"\n"
+ "REGION ID ... " + region.getIdentifier()+"\n"
+ "UUID ..." + region.getProximityUUID());
Log.i(TAGi, "Beacon List ... " +list);
showNotification("Welcome to Store","blah blah", region.getMajor(), region.getMinor());
} // EO onEnter Region
… and the result:
> 06-17 08:34:29.579 10580-10593/com.softserveapps.instore D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=5
> 06-17 08:34:35.367 10580-10580/com.softserveapps.instore I/INFO RUNNING APP: MAJOR ID ...20001
> MINOR ID ... null
> REGION ID ... store chain region
> UUID ...b9407f30-f5f8-466e-aff9-25556b57fe6d
> 06-17 08:34:35.368 10580-10580/com.softserveapps.instore I/INFO RUNNING APP: Beacon List ... [Beacon{macAddress=[E2:EF:4D:6D:1A:3A], proximityUUID=b9407f30-f5f8-466e-aff9-25556b57fe6d, major=20001, minor=10001, measuredPower=-74, rssi=-82}]
The MinorID is showing a null as region.getMinor() … this I have not seen before. I have checked perhaps picking up other beacons [no] … displaying “list” of beacons shows the beacon and both major and minor correctly.
TEST: I tested hardcoding the MinorID in the monitor i.e. from “null” to “10001” … then it works … its almost like the startMonitoring is acting like startRanging for a specific beacon?
06-17 08:39:01.458 10580-10580/com.softserveapps.instore I/INFO RUNNING APP: MAJOR ID ...20001
MINOR ID ... 10001
REGION ID ... store chain region
UUID ...b9407f30-f5f8-466e-aff9-25556b57fe6d
06-17 08:39:01.459 10580-10580/com.softserveapps.instore I/INFO RUNNING APP: Beacon List ... [Beacon{macAddress=[E2:EF:4D:6D:1A:3A], proximityUUID=b9407f30-f5f8-466e-aff9-25556b57fe6d, major=20001, minor=10001, measuredPower=-74, rssi=-80}]
… maybe I’m doing something wrong somewhere. Have you come across this before … can you perhaps see what my problem is?
KR
William.
In startMonitoring
, you set minor to null
for your region. So then in the onEntered
, region.getMinor() will also be null.
If you want to learn the minor value of the beacon’s nearby, even if you’re monitoring with the minor set to “null”, you can use the “list” parameter in the onEnteredRegion—although AFAIR, it’s not guaranteed to contain the beacon that triggered the event, so an alternative idea would be to start ranging in onEntered
, discover the minor value, and then stop ranging.