I have been trying to modify the reference app from AltBeacon in order to detect iBeacons.
In RangingActivity, I replaced
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ranging);
beaconManager.bind(this);
}
with
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ranging);
BeaconParser bp = new BeaconParser();
bp.setBeaconLayout("m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24");
List<BeaconParser> lbp = beaconManager.getBeaconParsers();
lbp.add(bp);
beaconManager.bind(this);
}
In order to apply the modifications to detect an iBeacon which I found here.
However this throws as lbp
is a java.util.Collections$UnmodifiableRandomAccessList. I am new to Java but I guess this is a list to which I cannot add items and something must have changed in the library between the solution in the second link and now.
Do anybody know what would be the correct way to add a new BeaconParser
or what I am doing wrong here ?