Last active
August 29, 2015 14:03
-
-
Save brandhill/42a884a3057c14cf454a to your computer and use it in GitHub Desktop.
Android - Getting the IP address of client or getting the information(SSID) of Clients connected to Hotspot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void getClientList() { | |
int macCount = 0; | |
BufferedReader br = null; | |
try { | |
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) { | |
// Basic sanity check | |
String mac = splitted[3]; | |
if (mac.matches("..:..:..:..:..:..")) { | |
macCount++; | |
ClientList.add("Client(" + macCount + ")"); | |
IpAddr.add(splitted[0]); | |
HWAddr.add(splitted[3]); | |
Device.add(splitted[5]); | |
Toast.makeText( | |
getApplicationContext(), | |
"Mac_Count " + macCount + " MAC_ADDRESS " | |
+ mac, Toast.LENGTH_SHORT).show(); | |
for (int i = 0; i < splitted.length; i++) | |
System.out.println("Addressssssss " | |
+ splitted[i]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment