I have made my iphone 4s an iBeacon and able to detect this using Locate Beacon app from my Glaxy S4, 5.01, I have also detected this using beacon reference library by modifying its layout found from this question. Its showing the detect beacon in device logs from the library files as below,
onScanResult() - ScanResult{mDevice=6C:64:80:68:86:59, mScanRecord=ScanRecord [mAdvertiseFlags=26, mServiceUuids=null, mManufacturerSpecificData={76=[2, 21, -96, -54, 104, -88, 101, -76, 75, 30, -66, -91, 73, -91, -114, -5, -124, 29, 0, 0, 0, 0, -59]}, mServiceData={}, mTxPowerLevel=-2147483648, mDeviceName=null], mRssi=-46, mTimestampNanos=162979288294680}
i am getting device name always null, and also unable to get the uuid, and i can't get that in my application, can any one please help how can i get beacon info in my application ?
Also How can i uniquely identify a beacon?
Here's what i have done so far, downloaded a ALT beacon library, then ALT beacon library reference, added library dependency, and written the following code in Ranging Activity class,
modified the onCreate method as
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ranging);
beaconManager = BeaconManager.getInstanceForApplication(this);
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout("m:0-3=0215,i:4-19,i:20-21,i:22-23,p:24-24")); // iBeacons
beaconManager.bind(this);
}
and implements this by BeaconConsumer, and added his method as
@Override
public void onBeaconServiceConnect() {
// TODO Auto-generated method stub
beaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
if (beacons.size() > 0) {
Log.i(TAG, "The first beacon I see is about "+beacons.iterator().next().getDistance()+" meters away.");
}
}
});
try {
beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
} catch (RemoteException e) { e.printStackTrace(); }
}
if i run the code without,
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout("m:0-3=0215,i:4-19,i:20-21,i:22-23,p:24-24")); // iBeacons
then it works fine when add this statement get exception as mentioned before.
Finally i am able to identify my problem, my beacon parser was wrong
i was using this while i correct results that detects an ibeacon for me are given by this parser