连接名称重复且有空白(Android)

时间:2018-07-19 12:32:37

标签: android listview

我想更改我的wifi连接而没有任何重复,我获得了几次相同的连接名称,甚至得到了一些没有名称的连接。我尝试了几种不同的方法,但没有成功,有些已被注释掉。有什么建议吗?我是android新手。

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int menuItemSelected = item.getItemId();
    if (menuItemSelected == R.id.action_refresh) {
        System.out.println("Refresh Clicked");


        wifiManager.startScan();

        //ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
        //NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();

        WifiInfo wifiInformation = wifiManager.getConnectionInfo();

        SSID = wifiInformation.getSSID();
        //address = wifiInformation.getMacAddress();
        SSID = SSID.replaceAll("\"", "");

        System.out.println("Current MAC: " + address);
        System.out.println("Current SSID: " + SSID);
        if(SSID.contains(filterText)){
        //buttonSubmit.setClickable(true);
        }
        /*
        if(!unitSSID.isEmpty()) {
            System.out.println("unitSSID is "+ unitSSID);
            int selectedUnitPosition = unitListAdapter.getPosition(unitSSID);
            System.out.println("selectedUnitPosition = " + selectedUnitPosition);
            listViewUnitDetected.setItemChecked(selectedUnitPosition,true);
            //unitList.
        }*/
    }
    return super.onOptionsItemSelected(item);
}

0 个答案:

没有答案