I would like to programmatically find the IP addresses of computers which are connected via WiFi to an Android device or emulator. How do I do this?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
If you want to detect the ip address of the "Emulator" or android device which is connected to any Network then use this code in Your program. it will give you the exact IP Address which the network have assign to your device.
As stated in another topic, the android Emulator works on a virtual private network.
Which means that the emulator is NOT on the same network as your computer, but on a virtual one. No emulator can see other devices, nor other emulators, nor other devices can see the emulators.
Apart from that I have a question:
How can I get the IP address of a hostname using the WifiManager?
For example, my PC is on the same LAN as my android phone (not emulator), and it has a hostname like User-PC. When I try to get the IP with InetAddress.getByName("User-PC"); on a java application, I get the LAN IP like 192.168.1.100, but when I try it on the phone it doesn't work.. Weird thing is I can establish connections if I know the IP, but cant seem to resolve it from the hostname.
Any ideas?
Can you share the logcat, I suspect there might be some other issue.Try this code (as is) in a sample application to check only if Wi-Fi IP address is working
Try this Android How to find Dynamic IP from device?