It was brought to our attention that there was a need to create a library that acted as a wrapper for some common calls to the SmartSDK WebAPI via an Android based application.
We decided to create one that will allow you to get the following data:
- Serial Number of the device
- Model Name of the device
- Ip Address
- Mac Address
- Host Name
The attachment to the library is below and keep in mind that its in an Alpha stage so we are just providing a sample application that uses the library.
We plan to provide java docs, finalize the sample app and user documentation once the beta package is available. (Goal is for sometime in April 2017.) In the meantime, please provide your feedback and let us know if there are any other WebAPI calls that would fit nicely into this Util library.
Below is a sample of how to get an instance of the SmartSdkAppUtil class and call to obtain some of the properties that will be made available for your Applications needs.
Usage:
SmartSdkAppUtil smartSdkAppUtil = SmartSdkAppUtil.getInstance();
smartSdkAppUtil.getSmartSDKAttributes();
.....
public static final String getSmartSDKAttributes() {
StringBuffer libContents = new StringBuffer();
libContents.append("Model Name: " + smartSdkAppUtil.getDeviceModelName() + "\n");
libContents.append("Serial Number: " + smartSdkAppUtil.getDeviceSerialNumber() + "\n");
libContents.append("Host Name: " + smartSdkAppUtil.getDeviceHostName() + "\n");
libContents.append("Ipv4 Address: " + smartSdkAppUtil.getDeviceIv4Address() + "\n");
libContents.append("Mac Address: " + smartSdkAppUtil.getDeviceMacAddress() + "\n");
return libContents.toString();
}
Add the following retrofit2 and gson libraries to your gradle file:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:19.1.0'
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.squareup.retrofit2:converter-gson:2.2.0'
compile files('C:/Users/gramirez/AndroidStudioProjects/LifecycleEvents/libs/SmartSDKFunctionLib.jar')
}
Disclaimer: The library is to be evaluated first and then added to any production code. Keep in mind we are using retrofit for our http client and gson for mapping the json data from the WebAPI