AirWatch Android SDK implementation walkthrough


This article helps demonstrate how to add the SDK to your project. Android Studio is being used for the example project throughout this article. If you do not have a prior version of AirWatch SDK, contact your account representative to request access. 


Acquiring the AirWatch Android SDK

The AirWatch SDK is available via the Resources portal of myAirWatch. To download the SDK, use the following steps:

  • Download the zipped SDK files
  • Unzip the SDK files
  • The SDK libraries are located in Android SDK 1.2.1 > libs; The AirWatch SDK_1.2.1.jar and son-2.1.jar files will need to be copied to the targeted project.


Adding the SDK jar files to the project

These jar files are generally added to the libs directory of the project. In the same project the libs directory is located within my "App" directory.

This particular sample project structure is as follows:


In the example Sample Terminal Output from the project that follows, notice the libs directory is located within the App directory. 



Android SDK_1.2.1.jar, gson-2.1.jar need to be manually copied to the libs directory. These files are located in the SDK that is downloaded from the AirWatch Resource portal and can be added using a file browser utility on your development machine. 



After completing the preceding steps, these libraries need to be specifically added to the Android Project. Completing this will allow you to use autocompletion features of the IDE. 

  1. Right click (Windows) or cmd click (Mac) on one of the library files.
  2. Select Add as Library
  3. Click OK to add the libraries to the project.
  4. The libraries have now been successfully added to the project. 


Link the Support library to your project

There are two ways to link the Support library to your project. The first method is to allow gradle to reach out and pull the jar down from the Internet (this is a preferred method). You can specify a specific version and get updates during the build process. The following screenshot is from the build.gradle file located in the "App" directory. 



The second option is by downloading the jar from the Internet and adding it the same way demonstrated previously for the other libraries. 


Add the receiver to the Manifest file (optional for SDK 1.2.1 and above)

In the following example, the AndroidManifest.xml file is located in App > src > main.



The following XML needs to be added to the manifest file for the project.

<receiver android:name="com.airwatch.sdk.AirWatchSDKBroadcastReceiver"
android:permission="com.airwatch.admin.sdk.BROADCAST" >
<action android:name="AppPackageID.airwatchsdk.BROADCAST" />


It is added within the <application> tag.



Implementing the AirWatchSDKIntentService class

The next step is to extend the AirWatchSDKBaseIntentService. This new class will have four callback methods within it. These callbacks will help extend some SDK functionality automatically after your Intent Service is implemented. The custom SDK Intent Service needs to be created at the application root directory and the specific implementation of each callback will need to be handled by the Developer depending on the Use case. 



Within the new Class, import the following four classes:

  • android.content.Context
  • com.airwatch.sdk.AirWatchSDKBaseIntentService
  • com.airwatch.sdk.profile.AnchorAppStatus
  • com.airwatch.sdk.profile.ApplicationProfile



Next, inherit from the AirWatchSDKBaseIntentService



Finally, add the following four methods that are required in our subclassed Intent Service:

  • onApplicationProfileReceived(Context context, String profileId, ApplicationProfile awAppProfile)
  • onClearAppDataCommandReceived(Context context)
  • onAnchorAppStatusReceived(Context ctx, AnchorAppStatus appStatus)
  • onAnchorAppUpgrade(Context ctx, boolean isUpgrade)



Finishing Up

The basic SDK functionality has been added to the project. The application can be built and deployed to devices. At this time there is not a large amount the SDK will be performing in the application and additional implementation will be required in order to fully implement the desired use cases. In order for the application to use the SDK properly, the application will need to be pushed as a managed application to devices enrolled into AirWatch. 

Have more questions? Submit a request


Article is closed for comments.