java - isReachable() returns false in android -


well, have situation when phone working hotspot , need detect devices wich connected phone , find mac addresses. wrote this:

public void getlistofconnecteddevice() {     thread thread = new thread(new runnable() {          @override         public void run() {             bufferedreader br = null;             boolean isfirstline = true;              try {                 br = new bufferedreader(new filereader("/proc/net/arp"));                 string line;                  while ((line = br.readline()) != null) {                     if (isfirstline) {                         isfirstline = false;                         continue;                     }                      string[] splitted = line.split(" +");                      if (splitted != null && splitted.length >= 4) {                          string ipaddress = splitted[0];                         string macaddress = splitted[3];                         boolean isreachable = inetaddress.getbyname(                                 splitted[0]).isreachable(300);// network call cant on ui thread, take background thread.                         log.d(tag, "ip: " + splitted[0]);                         log.d(tag, "isreachable: " + isreachable);                         if (isreachable) {                             log.d("device information", ipaddress + " : "                                     + macaddress);                             macaddresses.add(macaddress); //my list<string>                         }                     }                 }             } catch (exception e) {                 e.printstacktrace();             } {                 try {                     br.close();                 } catch (ioexception e) {                     e.printstacktrace();                 }             }         }     });     thread.start(); } 

but boolean isreachable = inetaddress.getbyname( splitted[0]).isreachable(300); returns false if device connected or disconnected. , can't find info find solution. or there other solutions? (for not rooted phones).


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -