2. Android gets information about devices connected to a mobile hotspot

Source: Internet
Author: User

Transferred from: http://blog.csdn.net/beijingshi1/article/details/9119297

Recently developed a project, encountered a problem, in the case of mobile phone hotspot, want to get which device has been connected on the Android phone open hotspot.

After Google,baidu, no answer was found.

Finally remembered in the foreign forum downloaded an AP Demo, looked at the source code, and finally found a solution to the problem.

As follows: This method is certainly familiar to the Linux developers think of the way, with the re file manager to "/proc/net/arp", in a look, found the connection hotspot device information is here, including Mac IP, etc.

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~~~~

2. Android gets information about devices connected to a mobile hotspot

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.