3

I'm trying to create an app that scans for wifi. When the player does something in the game, it "consumes" the strongest wifi signal. That signal should no longer be detected on the next scan.

Anyone who's played Metal Gear Solid Portable ops would know what I mean.

I tried to do this by creating a List of Wireless Signals that have already been used by the player and can no longer be detected again. The problem is that after scanning the best network, I scan again and it still displays the same network instead of ignoring it.

public void onClick(View arg0) {

    if (arg0.getId() == R.id.bStart) {
        ActivityLoader.loadMain(this);
    }

    if (arg0.getId() == R.id.bScan) {
        Toast.makeText(this, "Searching....", Toast.LENGTH_LONG).show();
        for (ScanResult selectedSpot : networkList) {
            {
                if (firstSignal == null || checkIfNotUsed(firstSignal)) {
                    firstSignal = selectedSpot;
                    usedNetworks.add(firstSignal.SSID);
                    break;
                }
            }

        }
    }
    if (firstSignal != null) {
        Toast.makeText(
                this,
                "Found Food and Ammo at the " + firstSignal.SSID
                        + " store.", Toast.LENGTH_LONG).show();

        // textStatus.setText(usedNetworks.toString());
        textStatus.setText(networkList.toString());
    } else {
        Toast.makeText(this, "Found nothing!!!", Toast.LENGTH_LONG).show();
    }
}
private boolean checkIfNotUsed(ScanResult selectedSpot) {
    // TODO Auto-generated method stub
    boolean flag = true;
    if (usedNetworks.isEmpty()) {
        flag = true;
    } else {
        for (String used : usedNetworks) {
            if (selectedSpot.SSID.equals(used)) {
                flag = false;
                break;
            }
        }
    }
    return flag;
}
4

0 回答 0