Beacons are found through RangingListener but in continuous manner. I want to show list of identical beacon UUID with some URL so that, when user click on beacon UUID assigned url will be open.
My code here
beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
@Override
public void onServiceReady() {
beaconManager.startRanging(ALL_ESTIMOTE_BEACONS_REGION);
beaconManager.startNearableDiscovery();
beaconManager.startMonitoring(ALL_ESTIMOTE_BEACONS_REGION);
}
});
beaconManager.setRangingListener(new BeaconManager.RangingListener()
{
@Override
public void onBeaconsDiscovered(Region region, List beacons)
{
try {
if (!beacons.isEmpty()) {
for (int i = 0; i < beacons.size(); i++)
{
String[] separeted = beacons.toString().split(",");
String[] onlyUUID = separeted[1].split("=");
TextView newtxt = new TextView(MainActivity.this);
newtxt.setText(onlyUUID[1].toString());
newtxt.setTextColor(android.graphics.Color.BLACK);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
// params.setMargins(a, b, c, d);
newtxt.setLayoutParams(params);
LinearLayout msg = (LinearLayout) findViewById(R.id.LinearL);
msg.setOrientation(LinearLayout.VERTICAL);
msg.addView(newtxt);
}
}
}
}
I created LinearLayout to dynamically create and show TextView for each beacon.
But I got same beacon multiple times as I need it once.
Every suggestions will be appreciated.