Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get MAC Address of android device without Wifi

Tags:

How do I get the MAC-Address of the network interface of an android device which doesn't have a Wifi-Interface (e.g. the android emulator)? WifiInfo obtained via the WifiManager returns null.

EDIT

To be more clear: I have to communicate with an existing network protocol (not designed by me) on the local network where I have to send the mac address of the communicating interface within the payload during a registration phase.

like image 427
Tom Avatar asked May 31 '11 18:05

Tom


People also ask

How do I find the MAC address of a Google home without Internet?

To find a MAC address without Wi-Fi, connect to a mobile hotspot and view the MAC address from Connect to Wi-Fi > Show MAC address.


2 Answers

I'm going to take a leap and assume that you want this MAC address in order to establish a unique identifier for the device. Mac Addresses are not the way to do this.

There's an Android Developer Blog post titled "Identifying App Installations" which covers the topic of generating unique ID's fairly well, including the popular methods, and the pros/cons. It's definitely worth a read. Quite relevant to this post is the following quote:

It may be possible to retrieve a Mac address from a device’s WiFi or Bluetooth hardware. We do not recommend using this as a unique identifier. To start with, not all devices have WiFi. Also, if the WiFi is not turned on, the hardware may not report the Mac address.

The options available to you instead include TelephonyManager.getDeviceId(), android.os.Build.SERIAL, and Settings.Secure.ANDROID_ID, all of which are covered in more detail in the linked post.

like image 114
Alexander Lucas Avatar answered Oct 08 '22 14:10

Alexander Lucas


Read /sys/class/net/[something]/address as a text file

But it's unlikely to be useful in the way you think.

like image 42
Chris Stratton Avatar answered Oct 08 '22 14:10

Chris Stratton