From: http://blog.csdn.net/beijingshi1/article/details/9119297
I recently developed a project and encountered a problem. When the hotspot is enabled on the mobile phone, I want to find out which device is connected to the hotspot enabled on the Android phone.
After Google and Baidu, no answer was found.
Finally, I remembered that I downloaded an AP demo in a Foreign Forum, looked at the source code, and finally found a solution to the problem.
As follows: This method must be familiar with the ideas of Linux developers. Use the re File Manager to go to "/proc/NET/ARP, the device information of the hotspot is found here, including the mac ip address.
Private arraylist <string> getconnectedip (){
Arraylist <string> connectedip = new arraylist <string> ();
Try {
Bufferedreader BR = new bufferedreader (New filereader (
"/Proc/NET/ARP "));
String line;
While (line = Br. Readline ())! = NULL ){
String [] splitted = line. Split ("+ ");
If (splitted! = NULL & splitted. length> = 4 ){
String IP = splitted [0];
Connectedip. Add (IP );
}
}
} Catch (exception e ){
E. printstacktrace ();
}
Return connectedip;
}
Call method:
Arraylist <string> connectedip = getconnectedip ();
Resultlist = new stringbuilder ();
For (string IP: connectedip ){
Resultlist. append (IP );
Resultlist. append ("\ n ");
}
System. Out. Print (resultlist );
Over ~~~~