The application can use application level authentication or not for initialization with the AWFramework.

Latest versions of the SDK automatically intialize both the context and gateway so you do not have to manually intialize the VMware Tunnel.

Application Level Authentication

Create a class which extends AWApplication and overrides applicable methods.

  1. Create a class that extends the AWApplication class to pass configuration keys to the login module, and override the getMainActivityIntent() and getMainLauncherIntent() methods in the extended class. Move your onCreate() business logic to onPostCreate().

    The onSSLPinningValidationFailure() and onSSLPinningRequestFailure() callbacks are called when SSL pinning validation fails for the backend server (denoted by "host"). If the application does not use SSL pinning, you can leave these callbacks empty.

    public class AirWatchSDKSampleApp extends AWApplication {
                            
                            /**
                            * This method must be overridden by application.
                            * This method should return Intent of your application main Activity
                            *
                            * @return your application's main activity(Launcher Activity Intent)
                            */
                            @Override
                            public Intent getMainLauncherIntent() {
                            return new Intent(getAppContext(), SDKSplashActivity.class);
                            }
                            
                            @Override
                            protected Intent getMainActivityIntent() {
                            Intent intent =  new Intent(getApplicationContext(), MainActivity.class);
                            return intent;
                            }
                            
                            @Override
                            public void onPostCreate() {
                            	    super.onPostCreate();
                            	    // App code here
                            }
                            
                            @Override
                            public void onSSLPinningValidationFailure(String host, @Nullable X509Certificate x509Certificate)
                            {
                            }
                            
                            @Override
                            public void onSSLPinningRequestFailure(String host, @Nullable X509Certificate x509Certificate)
                            {
                            }
                            }
                            
                            
                            
                         

    Optional Methods to Override

    Override the methods to enable Workspace ONE UEM functionality in the AWApplication class.

    • getScheduleSdkFetchTime()- Override this method to change when the login module fetches updates to SDK settings from the Workspace ONE UEM console.
    • getKeyManager() – Override this method to a value rather than null so that the login module initializes another key manager and not its own.
  2. In the manifest header file, declare tools.

    <?xml version  = "1.0" encoding = "utf-8"?>
                            <manifest xmls:android = http://schemas.android.com/apk/res/android
                            package = "<your app package name>"
                            xmlns:tools = "http://schemas.android.com/tools">
                            
                            
                            
                         
  3. Declare the tools:replace flag in the application tag that is in the manifest.

    <application
                            android:name  = ".AirWatchSDKSampleApp"
                            android:allowBackup = "true"
                            android:icon = "@mipmap/ic_launcher"
                            android:label "@string/app_name"
                            android:suportRtl = "true"
                            android:theme = "@style/AppTheme"
                            tools:replace = "android:label">
                            
                            
                            
                         
  4. Set the SDKSplashActivity as your main launching activity in the application tag.

    <activity
                            android:name="com.airwatch.login.ui.activity.SDKSplashActivity"
                            android:label="@string/app_name">
                            <intent-filter>
                            <action android:name="android.intent.action.MAIN" />
                            <category android:name="android.intent.category.LAUNCHER" />
                            </intent-filter>
                            </activity>
                            
                            
                            
                         
  5. In the AndroidManifest, add the certificate pinning meta tags under the opening application tag.

        <meta-data android:name="com.airwatch.certpinning.refresh.interval" android:value="1"/>
                            <meta-data android:name="com.airwatch.certpinning.refresh.interval.unit" android:value="DAYS"/>
                            
                            
                            
                         

    Here is an example of the launching activity and the certificate pinning code.

    <application
                            android:name=".AirWatchSDKExampleApp"
                            android:icon="@mipmap/ic_launcher"
                            android:label="@string/app_name"
                            android:supportsRtl="true"
                            android:theme="@style/AppTheme"
                            tools:replace = "android:label">
                            
                            <meta-data android:name="com.airwatch.certpinning.refresh.interval" android:value="1"/>
                            <meta-data android:name="com.airwatch.certpinning.refresh.interval.unit" android:value="DAYS"/>
                            
                            	<receiver
                            android:name="com.airwatch.sdk.AirWatchSDKBroadcastReceiver"
                            android:permission="com.airwatch.sdk.BROADCAST">
                            <intent-filter>
                            <action android:name="<packagename>.airwatchsdk.BROADCAST" />
                            </intent-filter>
                            <intent-filter>
                            <action android:name="android.intent.action.PACKAGE_ADDED" />
                            <action android:name="android.intent.action.PACKAGE_REMOVED" />
                            <action android:name="android.intent.action.PACKAGE_REPLACED" />
                            <action android:name="android.intent.action.PACKAGE_CHANGED" />
                            <action android:name="android.intent.action.PACKAGE_RESTARTED" />
                            <data android:scheme="package" />
                            </intent-filter>
                            </receiver>
                            
                            <activity
                            android:name="com.airwatch.login.ui.activity.SDKSplashActivity "
                            android:label="@string/app_name">
                            <intent-filter>
                            <action android:name="android.intent.action.MAIN" />
                            <category android:name="android.intent.category.LAUNCHER" />
                            </intent-filter>
                            </activity>
                            
                            <activity android:name=".MainActivity" />
                            
                            </application>
                            
                            
                            
                            
                         
  6. Add the sdkBranding to the application theme. The system displays this logo on the login screen. You can also use your own icon located in the mipmap directory.

    <style name="SDKBaseTheme" parent="Theme.AppCompat.Light">
                            // Replace with your own app specific resources to have branding
                            <item name="awsdkSplashBrandingIcon">@drawable/awsdk_test_icon_unit_test</item>
                            <item name="awsdkLoginBrandingIcon">@drawable/awsdk_test_icon_unit_test</item>
                            <item name="awsdkApplicationColorPrimary">@color/color_awsdk_login_primary</item>
                            </style>
                            <intent-filter>
                            <action android:name="android.intent.action.MAIN" />
                            <category android:name="android.intent.category.LAUNCHER" />
                            </intent-filter>
                            
                            
                            
                         
  7. If you need the SDK authentication, DLP, and timeout behavior, app activities should extend from SDKBaseActivity. These activities allow the application to handle the lifecycle correctly and to manage the state of the SDK.