An Android library providing Wrapper APIs to interact with beacons.
IMPORTANT: By default, this library will only detect ibeacons specification.
This library scan iBeacons and provide appropriate sorted data based on beacon payload.In addition it will provide data based on how much beacon far/near from person.
dependencies {
implementation 'com.github.MohitAndroid:AndroidBleBeaconWrapper:1.0.2'
}
BLEBeaconWrapper bleBeaconWrapper = new BLEBeaconWrapper(this);
String url = "http://api.plos.org/search?q=title:DNA";
Map headerMap = new HashMap<>();
headerMap.put("Accept", "*/*");
headerMap.put("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36");
bleBeaconWrapper.getBeaconData(url,
DNAEntity.class, headerMap, 3000, new BleBeaconListener() {
@Override
public void onBeaconDataResult(List list) {
Log.d("BLE-RESPONSE", "Total : " + list.size());
for (int i = 0; i < list.size(); i++) {
Log.d("BLE-RESPONSE", "Inside : " + list.get(i).getBeaconDetail().getBluetoothAddress()
+ " | Accuracy : "+list.get(i).getBeaconDetail().getAccuracy());
}
}
@Override
public void onError(String errorMsg) {
Log.d("BLE-RESPONSE", "" + errorMsg);
}
@Override
public void onShowProgress() {
Log.d("BLE-RESPONSE", "onShowProgress");
}
@Override
public void onParsableDataResult(List parsableData) {
Log.d("BLE-RESPONSE", "onParsableDataResult");
//Your json parsable data list
}
});
BLEBeaconWrapper1 bleBeaconWrapper = new BLEBeaconWrapper(this);
bleBeaconWrapper1.getBeaconData(1000, new BeaconListener() {
@Override
public void onResult(List beaconResultEntities) {
for (int i = 0; i < beaconResultEntities.size(); i++) {
Log.d("BLE-RESPONSE", "Beacon : " + beaconResultEntities.get(i).getBluetoothAddress());
}
Log.d("BLE-RESPONSE", "***********************************");
}
@Override
public void onError(String errorMsg) {
}
});