我想显示当前距离,该距离是通过选定信标上的AltBeacon库中的getDistance()函数计算出来的。使用Android上的Altbeacon库刷新到选定的iBeacon设备的距离
例如我已经在范围3个信标和它们的2保存在SavedBeacons - 这是收集的信标对象。用户从public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region)
功能中选择了信标。
我想有显示他们(只有选定的)与自动1秒更新上thier当前距离。
现在的产量仅仅是信标信息,并保存在我已经将其添加到收藏SavedBeacons的时间距离。它的距离没有更新。
这里是我的类活动,以显示选定的信标:
public class SelectBeacon extends Activity {
private ListView listview;
private AdapterBeaconDevices bAdapter;
private TextView noBeaconsFound;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_select_beacon);
this.bAdapter = new AdapterBeaconDevices(this, SavedBeacons);
listview = ((ListView) findViewById(R.id.listView2));
listview.setAdapter(bAdapter);
noBeaconsFound = (TextView) findViewById(R.id.empty2);
SetEmptyButtonVisiblity(SavedBeacons.size());
listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
//nothing yet
}
});
refresh();
}
private void refresh(){
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
Toast.makeText(SelectBeacon.this, "test_refresh_msg",
Toast.LENGTH_LONG).show();
bAdapter.notifyDataSetChanged();
handler.postDelayed(this, 1000);
}
}, 1000);
}
private void SetEmptyButtonVisiblity(final int a)
{
runOnUiThread(new Runnable() {
@Override
public void run() {
if (a == 0) {
noBeaconsFound.setVisibility(View.VISIBLE);
} else {
noBeaconsFound.setVisibility(View.GONE);
}
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
}
@Override
protected void onPause() {
super.onPause();
}
@Override
protected void onResume() {
super.onResume();
}
}
哪里你的代码获得远程灯塔回调?我们需要看看这些数据是如何处理的。 – davidgyoung