Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 4. Permissions, Certificates, an... > Controlling Distribution by Using th...

4.5. Controlling Distribution by Using the MAC Address

You may need to develop an application that is only authorized to run on some devices. You could upload it to a server and give the URL to a selected group, but this method is not very secure.

To monitor installation, use the MAC address of the device. The MAC address is the unique identifier for the hardware, mobile device, or desktop.

First, set the Android permissions to have access to network information:

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

To obtain the address at runtime, use the NetworkInfo class, which gets a list of interfaces and looks for a hardwareAddress. It is the MAC address for your device:

if (NetworkInfo.isSupported) {
    trace("network information is supported");
}

var network:NetworkInfo = NetworkInfo.networkInfo;
for each (var object:NetworkInterface in network.findInterfaces()) {
    if (object.hardwareAddress) {
        trace(object.hardwareAddress);
    }
}

The address looks something like this:

00:23:76:BB:46:AA.