Partager via


NetworkInterface.GetHardwareAddress Method

Definition

Returns the hardware address (usually MAC) of the interface if it has one and if it can be accessed given the current privileges.

[Android.Runtime.Register("getHardwareAddress", "()[B", "")]
public byte[]? GetHardwareAddress ();
[<Android.Runtime.Register("getHardwareAddress", "()[B", "")>]
member this.GetHardwareAddress : unit -> byte[]

Returns

Byte[]

a byte array containing the address, or null if the address doesn't exist, is not accessible or a security manager is set and the caller does not have the permission NetPermission("getNetworkInformation"). For example, this method will generally return null when called by non-system apps (or 02:00:00:00:00:00 for apps having targetSdkVersion < android.os.Build.VERSION_CODES.R).

Attributes

Exceptions

if an I/O error occurs.

Remarks

Returns the hardware address (usually MAC) of the interface if it has one and if it can be accessed given the current privileges. If a security manager is set, then the caller must have the permission NetPermission("getNetworkInformation").

Added in 1.6.

Java documentation for java.net.NetworkInterface.getHardwareAddress().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to