I am developing an app which detects for nearby beacons for the users to record a certain movement. I am using the AltBeacon library to do so. It works perfectly when I have the Bluetooth on.
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region)
{
Logr.d(TAG, "didRangeBeaconsInRegion size:" + beacons.size());
for (Beacon b : beacons)
{
try
{
String json = (new Gson()).toJson(beaconIdList);
Logr.d(TAG, json, "");
if (b.getId1() == null)
{
continue;
}
if (b.getId2() == null)
{
continue;
}
if (b.getId3() == null)
{
continue;
}
String id1 = b.getId1().toString();
String id2 = b.getId2().toString();
String id3 = b.getId3().toString();
String finalId = id1 + ":" + id2 + ":" + id3;
Integer index = beaconIdList.indexOf(finalId);
if (index >= 0)
{
// index = -1 means that no match
Logr.d(TAG, "beacon matched: " + finalId, "");
}
else
{
Logr.d(TAG, "beacon unmatched: " + finalId + ":" + b.getDistance(), "");
}
}
catch(Exception ex)
{
}
}
}
}
In some cases it may happen that the user turns of the Bluetooth. In such cases I still want to record the movement. With reference to this SO answer, it can be done on iOS using with the help of location services.
Is the same possible for Android?
Any suggestions will be a great help.