waiting for connection using do-while statement - java android -


Would like to make your comments on this code

  Private string getIpAddress () {String IP = ""; Try {enumeration & lt; Network Interface & gt; EnumNetworkInterface = NetworkInterface.getNetworkInterfaces (); While (enumNetworkInterfaces.hasMoreElements ()) {Network Interface Network Interface = enumNetworkInterfaces.nextElement (); Calculation & LT; InetAddress & gt; EnumInetAddress = networkInterface.getInetAddresses (); While (enumInetAddress.hasMoreElements ()) {InetAddress inetAddress = enumInetAddress.nextElement (); String ipAddress = ""; If (inetAddress.isSiteLocalAddress ()) {ipAddress = "SiteLocalAddress:"; IP + = inetAddress.getHostAddress () + "\ n"; }}} Hold (socket exception e) {// Todo auto-generated catch block e.printStackTrace (); IP + = "Something Wrong!" + E.toString () + "\ n"; } Return IP; } Private Zero MDConnector () {setMobileDataEnabled (MainActivity.This is true); String ip = getIpAddress (); Try {addMessage ("..") {Thread Solid (1000L); } Hold (Blocked Expression Local Interrupted Exception) {}} while (ip.length () & lt; = 0); MDConnect (); }  

It does not work. My goal is: Connect-> getIPAddress-> Wait for someone, wait till I go to another-> any other method in my code What is wrong? Can somebody help me out? thank you in advanced.

EDIT: getIpAddress code added. To credit,

IP-string has not been changed in its do-all loop. Try moving the part forward, where you get the IP-string IP in try-block.


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 -