searching for right ip address in an array of strings - java android -


I'm new to Android Java programming. I'm trying to write an app again.

I had an edit text that was matched by the "," IP prefixes matched. Like "10.15,10.31,10.42"

  Private Zero MDConnect () {string str = getIpAddress (); String [] arrayoffstring = edittext.gettext (). ToString () the division (","); J = 0 while (j & lt; arrayOfString.length) {if (str.substring (0, arrayOfString [j]) length (). Equals (arrayOfString [j])) {addMessage ("Success! Your IP address "+ Str); } Else {j ++;}} addMessage ("retry") // This is the process where the process will start. Disconnect and then connect to get the latest new IP address)  

My target-> getIpAdd-> check if it matches the list-> If yes, success message Add If not, then disconnect and reconnect.

Hope someone can help me, please. thank you in advanced.

Edit: The code is just checking the first string in the array. It's not going on looping or next string. Where can I say in my post how can I make a statement?

Your code is very muddy and the semi-colon and closing brackets are missing. And your loop can be very simple, although your method can work, you're making it as tough as it should be. Try this code:

  string str = getIpAddress (); String [] arrayoffstring = edittext.gettext (). ToString () the division (","); For (int i = 0; i & lt; arrayOfString.length; i ++) {if (str.substring (0, arrayOfString [i]) length (). Equals (arrayOfString [i]) {addMessage ( "Success! IP address" + str); break; } Else {// Not Found) AddMessage ("Retry")}}  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -