0

In my Android app I want to detect all Android device names found in the local wireless network. I am able to scan the network and find the devices IP and full qualified domain name (FQDN) like android-2120ee3b45******. I'm doing it like:

final InetAddress inetAddress = InetAddress.getByName(ip);
if (inetAddress.isReachable(400)) {
    final String host = inetAddress.getHostName();
    final String canHost = inetAddress.getCanonicalHostName();
    final String ip = inetAddress.getAddress();
}

With java.net.InetAddress I only get the IP and the network name like android-2120ee3b45******. But I want the Android device name defined by the user on the device like "Peters Fire TV" or "Mikes Samsung SGS6". I saw apps like AllConnect or AllCast which can grab such name from Fire TV (which is a android device).

How can I get the Android device name defined by the user over the WIFI network?

user4500
  • 667
  • 2
  • 9
  • 21

1 Answers1

1

add this line,

for(i=0;i<WifiP2pDeviceList.size();i++){
    WifiP2pDevice device = WifiP2pDeviceList.get(i);
    String deviceName=device.deviceName;
    String devicestatus=device.status;
    //so on
    }
  • I was not aware of the class WifiP2pDeviceList nor WifiP2pManager. So I have to implement Wi-Fi Peer-to-Peer? I will have a look into it. Thanks. – user4500 Oct 24 '15 at 02:50
  • I think This link help you for your query https://trivedihardik.wordpress.com/2012/08/31/android-wifi-direct-example/ – AndroidEnthusiastic Oct 26 '15 at 12:36
  • That's something different. This only lists active WiFi Direct devices. Nothing to do with regular WiFi devices connected to the LAN. – Gábor May 30 '22 at 09:41