将扫描的值存储到数组中,并在Android中找到最大值

Store the scanned value in array and find the largest value in Android

在我的 Beacon 应用程序中,我通过 beacon.getRSSI() 获得了不同的 RSSI 值。现在我想获得所有扫描信标的 RSSI 最大值。所以我认为可能的解决方案是数组。任何人都可以帮助如何做到这一点?

将所有的Beacon对象放入一个Collection(List, Set)中,然后用Collections.max得到RSSI最高的beacon。 javadoc

List<Beacon> beacons = new ArrayList<Beacon>();
// add all the beacons
beacons.add(beacon);

(...)

Beacon maxBeacon = Collections.max(beacons, new Comparator<Beacon>(){
    public int compare(Beacon b1, Beacon b2) {
        return Integer.compare(b1.getRSSI(), b2.getRSSI);
    }
}