In the latest SDK, the steps to initialize the AWFramework follows a different design pattern. The application can use application level authentication.

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().

    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
                            }
                            }
                            
                            
                            
                            
                         

    Optional Methods to Override

    Override the methods to enable AirWatch functionality in the AWApplication class.

    • getScheduleSdkFetchTime()- Override this method to change when the login module fetches updates to SDK settings from the AirWatch 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>
                            
                            
                            
                            
                         

    See the example.

    <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" 
                            >
                            <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>
                            
                            
                            
                         
  5. 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>
                            
                            
                            
                            
                         
  6. 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.