I want to make an android application that connects to a Wifi network, say network SSID = "ABC".Assume that it is connected to the Wifi ABC. After connecting to ABC, i would want my application to display the ips of all the android devices that are connected to the same wifi ABC network. How can i achieve that? Thanks
Asked
Active
Viewed 4,808 times
4
-
Welcome to Stack Overflow! Please avoid using answers to post additional information or follow up responses to other answers. Simply edit your question to provide clarification, or use the comments under each posted answer to interact with its author directly. – Tim Post Mar 12 '11 at 08:37
2 Answers
4
Check out the file: /proc/net/arp on your phone.
It has the ip and MAC addreses of all the other devices connected to the same network. However I am affraid you wont be able to differentiate if they are android phones or not.

daralthus
- 13,723
- 2
- 16
- 13
1
You will want to use tcpdump to put the network card into promiscous mode and then capture packets to identify what other clients are on your network.
How to use tcpdump on android: http://source.android.com/porting/tcpdump.html
You can run commands in your code like so:
try {
// Executes the command.
Process process = Runtime.getRuntime().exec("/system/bin/ls /sdcard");
// Reads stdout.
// NOTE: You can write to stdin of the command using
// process.getOutputStream().
BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
int read;
char[] buffer = new char[4096];
StringBuffer output = new StringBuffer();
while ((read = reader.read(buffer)) > 0) {
output.append(buffer, 0, read);
}
reader.close();
// Waits for the command to finish.
process.waitFor();
return output.toString();
} catch (IOException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}

radiofrequency
- 873
- 8
- 19
-
1Assuming that i am receiving packets designated for all devices, which includes any computer or mobile devices connected to the wifi, how would i be able to differentiate android devices from non-android devices just by looking at the packets ? Is there a way packets/process can be distinguished by the application sending/receiving the packets? – Farhan Mar 12 '11 at 06:06