I have raspberry pi which connected to my network and got its IP with DHCP dynamically.
I need the IP address of the raspberry pi in my Android program for my iot project.
In other OS I could use the nmap
or arp
commands, but I could not find a proper way in Android. I've already read these solutions, but they weren't helpful:
Since the Raspberry Pi is connected to the local network, you can get the list of connected devices and search for the device with the name 'raspberrypi'. This can be done by using socket programming in Java. Try opening up admin panel of your router and look for the hostname of Raspberry Pi(usually raspberrypi) with IP address. That hostname can be used to identify the IP address of the Raspberry Pi from Java code dynamically.
Your problem is similar to the one given in the below link.
How to get IP address and names of all devices in local network on Android
Pi-oi: a Tool for Finding Local IP Address of Your Raspberry Pi
Resolving ip-address of a hostname
There can be may other ways to find the IP address. Just use the one that suits your purpose.