How to get an IP address from Mac address programmatically on Android? - android

Programmatically, I got Mac addresses of other Wifi enabled devices from my device on the same network. Same I need to apply here. Is there any apps or any other possibilities to get an IP addresses of each wifi enabled devices on the network by using those Mac addresses on Android?

If you're looking for an android app, you could try Network Discovery which work very well and can list all the devices on your local network with the corresponding IP and address.
If you're looking for code instead, well the application is available on github and does (amongst other things ) basically the same thing than explained by Yahel : it reads /proc/net/arp .
Note : I'm NOT the author of this application.

This person does the exact opposite so it should work for you.
The trick is to read the ARP cache table from the device.
http://www.flattermann.net/2011/02/android-howto-find-the-hardware-mac-address-of-a-remote-host/

Related

Local network ARP requests from Android app

I'm working on an app interacting with Network Enabled devices on a local network.
I'm currently working with IP addresses. However, on the long run, IP addresses will eventually change, breaking the connection. I'd like to store MAC addresses instead, and init my app by sending ARP requests and fetching the matching IP address for each stored MAC.
Is this the correct way to do this?
If so, which library should I use for such a task, and do any of you have a code example?
Many thanks!
You will probably need to access low-level components which Android & Java don't allow you to. Maybe with a rooted device ?

Get the mac address of devices connected to same wifi in android

I know this question has been asked several times but there isn't a proper code snippet or answer in SO.
I am developing an android app which gives the list of MAC addresses (IP address or device name anything ,etc. ) of all the Devices connected to a wifi network (the network in which the mobile containing this app is installed).
Is there any API's in android to achieve this or else how can we do this.
Note : Please provide the answer with a code snippet
I think that it is not possible to get Mac Address of other devices. However you can get IP addresses.

How to obtain a list of IP addresses of all available android device

Obtain a List of IP addresses of all available android Devices.
Establish connection with one of IP.
Send Data to the Selected IP?.
If any body done this already, a little help would be great.
I guess you have to search for devices on your WiFi network. Then create a list with the devices (IP-addresses) you found. If you click on a device, send the data to the IP that belongs to that device.
To detect wether or not any device you find in the network is an Android device, is something else.
This article might be helpful to get you started, along with its subarticles: http://developer.android.com/training/connect-devices-wirelessly/index.html

How can I get netmask from Android device?

I need to get the netmask and ip from the Android so I can calculate all the IP's within my subnet range.
I've been searching and so far I've found this:
Programmatically getting the gateway and subnet mask details
The problem is that it doesn't work for all devices. For instance, it doesn't work in the emulator (any Android version) and it doesn't work either in my Archos 7HT with Android 1.5.
It returns 0 for netmask and gateway.
Is there any way to do it? Is there any system file which I could read that contains this info?? (something like this: http://www.flattermann.net/2011/02/android-howto-find-the-hardware-mac-address-of-a-remote-host/).
In my advanced wifi settings I can see these settings, so there must be a way to retrieve them...
Thanks.
Try with APIs InetAddress and NetworkInterface. Emulator has no WIFI, hence is not possible to get address with Wifi API.
Check this reply

Do Android Phones have a MAC address when connected to 3G?

I was wondering if Android phones have a MAC address when connected to the internet over 3G? I'm assuming they do, so I guess my real question is whether or not there is anyway of accessing it? I haven't found anything from looking through the APIs or by googling, but maybe I missed something.
Thanks in advance
MAC address is specific to network technologies that implement the IEEE 802 standard, such as ethernet. 3G is not an IEEE 802 network, so MAC address really doesnt apply.
That said, there should be very few reasons to use the MAC address in your app, unless youre writing a network driver or doing something specific with the TCP/IP network.
Often people reach for MAC address thinking that it represents a unique device id, when really you should use something like http://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID to get a unique id that will work across all of the different hardware combinations for android, some of which might include no IEE 802 network whatsoever.
I have never seen any reference to a 3G MAC address anywhere. The closest thing to a 3G MAC address that I know of is the IMEI/MEID code.
android.telephony.TelephonyManager.getDeviceId() will return the IMEI/MEID code.
If you are trying to uniquely identify app installs then see: http://android-developers.blogspot.com/2011/03/identifying-app-installations.html

Categories

Resources