I'm developing an app which requires Detect available Beacons near by your region and the detected beacon details need send to my server using API call. I'm getting beacon details but I'm not able to send the details to my server from background of app found any beacon.
Here is the details of Beacons;
private class ScanProcessor extends AsyncTask<ScanData, Void, Void> {
@Override
protected Void doInBackground(ScanData... params) {
ScanData scanData = params[0];
IBeacon iBeacon = IBeacon.fromScanData(scanData.scanRecord, scanData.rssi);
if (iBeacon != null) {
lastIBeaconDetectionTime = new Date();
trackedBeacons.add(iBeacon);
Log.d(TAG, "iBeacon detected :"+iBeacon.getProximityUuid()+" Major: "+iBeacon.getMajor()+" Minor: "+iBeacon.getMinor()+" accuracy: "+iBeacon.getAccuracy()+" proximity: "+iBeacon.getProximity());
List<Region> matchedRegions = matchingRegions(iBeacon, monitoredRegionState.keySet());
Iterator<Region> matchedRegionIterator = matchedRegions.iterator();
while (matchedRegionIterator.hasNext()) {
Region region = matchedRegionIterator.next();
MonitorState state = monitoredRegionState.get(region);
// if (state.markInside()) {
// state.getCallback().call(IBeaconService.this, "monitoringData", new MonitoringData(state.isInside(), region));
// }
}
Log.d(TAG, "looking for ranging region matches for this ibeacon");
matchedRegions = matchingRegions(iBeacon, rangedRegionState.keySet());
matchedRegionIterator = matchedRegions.iterator();
while (matchedRegionIterator.hasNext()) {
Region region = matchedRegionIterator.next();
Log.d(TAG, "matches ranging region: "+region);
RangeState rangeState = rangedRegionState.get(region);
rangeState.addIBeacon(iBeacon);
}
}
//I see a device: 00:02:72:C5:EC:33 with scan data: 02 01 1A 1A FF 4C 00 02 15 84 2A F9 C4 08 F5 11 E3 92 82 F2 3C 91 AE C0 5E D0 00 00 69 C5 0000000000000000000000000000000000000000000000000000000000000000
//
// 9: proximityUuid (16 bytes) 84 2A F9 C4 08 F5 11 E3 92 82 F2 3C 91 AE C0 5E
// 25: major (2 bytes unsigned int)
// 27: minor (2 bytes unsigned int)
// 29: tx power (1 byte signed int)
return null;
}
@Override
protected void onPostExecute(Void result) {
}
@Override
protected void onPreExecute() {
}
@Override
protected void onProgressUpdate(Void... values) {
}
}
Help me how to send beacon details to my server when I found the beacons in the app background.