3

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

3

3 Answers 3

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; } 
Sign up to request clarification or add additional context in comments.

Comments

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

Comments

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

3 Comments

Yes, i am looking for an api to perform the job done
Thanks for your reply, i actually try this post before but not work
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.