Product Documentation

Developing Android apps

You can use the XenMobile API in your mobile apps to allow the apps to interact with XenMobile. This article describes how to integrate the MDX App SDK into your app library and the steps required to test, certify, and publish your apps.

How to use the MDX App SDK

Here are some examples of how you might use the APIs.

Place restrictions on apps

You can control whether your app allows access to certain features or actions based on whether API calls indicate that the app is managed or wrapped. For example, if an app is not managed or wrapped, you might allow a user access to all features and actions. If an app is wrapped but not managed, you might then restrict certain features or actions. If an app is wrapped and managed, you might put additional restrictions on the app.

Perform actions based on XenMobile policy settings

Suppose that you want to display a notification to users if a XenMobile administrator sets the Require WiFi policy to On, which means that the app is allowed to run on a wireless network. You can use the API to look up the policy setting and then base your code changes on the policy value.

  • Perform actions based on custom policies

    You can use the APIs to read custom policies in your apps. For example, suppose that you want to enable XenMobile administrators to display a notification in the app. To do that, you can create a custom policy that is empty by default or contains a system message that is supplied by an administrator in the XenMobile console. When your app is managed, it can detect when the XenMobile administrator changes the policy value. If the policy value contains a message, your app displays the notification.

For API definitions, see XenMobile API for Android.

Integrating the SDK into your app library by using Android Studio and Gradle

To add the MDX App SDK to your Android apps, you import or copy the MDX App Java libraries into your app, as described in this section. The steps are based on Android Studio and the Gradle buld system. Going through the steps adds the MDX Apps SDK library to your application so that its classes and methods are accessible to the app.

  1. If you haven’t already installed the latest MDX Toolkit, do so now.

    1. Log on to the XenMobile downloads page.

    2. Expand XenMobile Apps and MDX Toolkit

    3. Locate the MDX Toolkit version you want to install and then click its link to begin the download.

    4. Open MDXToolkit.mpkg with the macOS Finder tool on macOS 10.9.4 or later and Xcode 5.1 or later.

    The installation path is Applications/Citrix/MDXToolkit.

    The MDX App SDK files are in Applications/Citrix/MDXToolkit/data/MDXSDK_Android.

  2. After installing the MDX Toolkit, install Android Studio from the Android developers website and then do the following:

    1. In the project directory, create a folder named libs.

    2. Add the file worxsdk.aar to the libs folder.

    3. Edit the project “build.gradle” to add a rule to search the libs folder as a repository and to include worxsdk.aar from the libs folder as a dependency.

    4. Build your APK file.

An example of worxsdk.aar:

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.1.0'
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    allprojects {
        repositories {
            jcenter()
            flatDir {
                dirs 'libs'
            }
        }
    }
    dependencies {
        compile(name:'worxsdk', ext:'aar')

The OpenSSL library might cause conflicts with similar libraries in Android apps. Citrix recommends that you use the Citrix versions of the libraries to avoid conflicts.

Publishing an Android app

After you add the MDX App SDK to an Android app, perform the following steps to wrap, test, certify, and publish the app. When wrapping apps by using the command-line interface, include one of the following options:

  • –appType Enterprise
  • -appType Premium
  • -appType General

The default is –appType Enterprise. Use the following guidelines to select the appType:

  • Enterprise: Apps require installing Secure Hub on the user device. Also, you must also publish the application in StoreFront and install the app through Secure Hub.
  • General: ISV Apps can run without Secure Hub (initially). The application can transition to managed mode when the app detects Secure Hub on the user device and if you publish a matching app. When running as a managed app, General apps behave the same as Enterprise apps. When running as an unmanaged app, Citrix policies are not enforced.
  • Premium: ISV apps can run without Secure Hub installed on the user device (initially). The app can transition to a managed app if it detects Secure Hub on the user device and if you publish a matching app. When the app runs unmanaged, MDX enforces some policies, such as the containment policies (allowing network access, screen capture, or blocking the camera).

If you need to upload the wrapped .apk file to an app store or web server, and you already know the URL, add the -storeURL option. You can also add the URL later, as indicated later in these steps.

The MDX Toolkit outputs a modified .apk file and a .mdx file. You will use those files in the following steps. Use the MDX Toolkit to wrap the .apk file for the app. For details, see Wrapping Android Mobile Apps in the MDX Toolkit documentation. That article includes all wrapping commands, including those specific to ISV apps.

Important:

The option to wrap ISV apps by using the MDX Toolkit user interface no longer available. You must wrap ISV apps by using the command line.

To test your app

  1. Install the modified .apk file on an Android device to verify all app functions.

  2. Use the XenMobile console to add the .mdx file to XenMobile and deliver it to an Android device for testing. For details, see To add an MDX app to XenMobile. On that device, test the MDX functionality of your app.

    If you added custom policies, be sure to verify that those policies appear in the XenMobile console and work as expected. If you changed default_sdk_policies.xml, test those changes. For details about adding policies and changing policy defaults, see Policy Defaults and Custom Policies.

  3. Fix any issues found in your app, regenerate the app .apk file, and wrap the app again with the MDX Toolkit.

  4. Submit the original .apk file (not the one output by the MDX Toolkit) to Citrix for validation and certification.

  5. After Citrix certifies your app, submit the .apk file generated by the MDX Tookit to the Google Play Store for approval.

  6. After Google approves your app, run the MDX Toolkit to update the app download URL in the .mdx file. An example command that changes the URL is as follows:

    java -jar /Applications/Citrix/MDXToolkit/ManagedAppUtility.jar \
    setinfo \
    -in ~/Desktop/SampleApps/Sample.mdx \
    -out ~/Desktop/SampleApps/wrapped/Sample.mdx \
    -storeURL \
    “https://play.google.com/store/apps/details?id=com.zenprise”
    
  7. Provide the final .mdx file to a XenMobile administrator, who will add it to XenMobile and publish it to users. Or, to make your app available for wider distribution, you can list your MDX verified app in the Citrix Ready Marketplace. For details, see Citrix Ready Worx Verified Program.

Considerations for upgrading apps

The XenMobile software changes significantly between releases. To take advantage of the latest features and bug fixes, you must use the latest version of the MDX Toolkit to wrap your app. Be sure to wrap your original .ipa or .apk file, not the modified file that was previously generated by the MDX Toolkit.

Be sure to use the corresponding version of the MDX App SDK.