By Olivier Brand
-
To install the plugin, move
MacAddress.jsto your project's www folder and include a reference to it in your html files.<script src="MacAddress.js"></script>
-
Create a folder called 'com/phonegap/plugin/macaddress' within your project's src folder.
-
And copy the java file into that new folder.
mkdir -p /src/com/phonegap/plugin/macaddress
cp ./ResourcesPlugin.java /src/com/phonegap/plugin/macaddress
- Set the permissions into the Android Manifest for accessing the mac address.
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
-
Add a plugin line to
res/xml/plugins.xml<plugin name="MacAddress" value="com.phonegap.plugin.macaddress.MacAddressPlugin" />
var networkInterface = {};
// Get network interface
networkInterface = window.plugins.macaddress.getMacAddress();
console.log(networkInterface.mac);