samedi 4 avril 2015

How to split a String into a sunstring and number

How can I split a string"KD-435" into two substrings to check whether the first substring "KD-"begins with the following characters"KD-" and the second substring is number beteewn "400-500". I have the following method and I want to change it to do that at this position "if (ssid.startsWith("KD-"))"





private void check_wifi_available() {
WifiManager wifiManager = (WifiManager) this
.getSystemService(this.WIFI_SERVICE);

final List<ScanResult> results = wifiManager.getScanResults();
if (results != null) {

List<ScanResult> updatedResults = new ArrayList<ScanResult>();
// pick wifi access ponits which begins with these "KD" characters.
for (int i = 0; i < results.size(); i++) {
String ssid = results.get(i).SSID;
if (ssid.startsWith("KD-")) {

updatedResults.add(results.get(i));
}
}
if (updatedResults.size() > 0) {
String a = calculateBestAccessPoint(updatedResults);
textWifi.setText(a.toString());
}
}
}



Aucun commentaire:

Enregistrer un commentaire