Get android device name defined by user over wifi

泪湿孤枕 提交于 2019-12-12 10:25:26

问题


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?


回答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
    }


来源:https://stackoverflow.com/questions/33296712/get-android-device-name-defined-by-user-over-wifi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!