i am writing an android app to control other devices if other devices is connected to my android phone's Wifi hotspot. However, i am unable to determine the ip address of the connected devices (say another android phone). Therefore, i am asking a way to determine the ip address of connected devices in my wifi hotspot. Thank you in advance
Asked
Active
Viewed 3.4k times
3
-
This page may help you to find your answer. http://android.stackexchange.com/questions/46649/how-to-get-the-information-of-users-connected-to-a-wi-fi-hotspot – Aravindan K Dec 10 '14 at 17:32
-
1But can i determine the ip in api method?? i would like to do it in automatically way – user3338304 Dec 10 '14 at 17:45
-
Try this code on the below link. http://stackoverflow.com/a/7049074/3847529 – Aravindan K Dec 10 '14 at 17:52
3 Answers
1
You can try this method for getting the list of devices connected to your hotspot. for pingCmd refer this
public ArrayList<String> getArpLiveIps(boolean onlyReachables) {
BufferedReader bufRead = null;
ArrayList<String> result = null;
try {
result = new ArrayList<String>();
bufRead = new BufferedReader(new FileReader("/proc/net/arp"));
String fileLine;
while ((fileLine = bufRead.readLine()) != null) {
String[] splitted = fileLine.split(" +");
if ((splitted != null) && (splitted.length >= 4)) {
String mac = splitted[3];
if (mac.matches("..:..:..:..:..:..")) {
boolean isReachable = pingCmd(splitted[0]);/**
* Method to Ping IP Address
* @return true if the IP address is reachable
*/
if (!onlyReachables || isReachable) {
result.add(splitted[0]);
}
}
}
}
} catch (Exception e) {
} finally {
try {
bufRead.close();
} catch (IOException e) {
}
}
return result;
}

Rishi Pandey
- 154
- 11
0
If your stock Android Hotspot app does not have this option. Use this app
https://play.google.com/store/apps/details?id=com.etustudio.android.hotspotmanager

Mukul Shukla
- 123
- 2
- 12
0
Unfortunately there is no official API for the hotspot, but you could use reflection, even though it might be difficult.
Also check out IP address of device using phone as access point
-
-
Thanks for your reply, i actually try this post before but not work – user3338304 Dec 10 '14 at 17:59
-
Your're welcome ;) But as mentioned, there is no official API. You'll need a lot of effort to build your own if you want so. – manniL Dec 10 '14 at 18:27