Integrating Air Watch Android Studio
Asked Answered
E

2

11

I am very much new to AirWatch Concept but had gone thoroughly about AirWatch. I have gone through the following links,

http://developer.air-watch.com/android/application-configuration-with-the-android-sdk/

http://developer.air-watch.com/android/android-sdk-setup/

but in vain.

Could anyone please help me regarding the integration of Air Watch in Android ?

Things i have done so far,

I have created app in the https://apidev.awmdm.com, and i have added assignemnts. The question here is, How can i get the assignment details in my android application that were added in the Air Watch Console.

Help is really appreciated.

Update:

I am able to create and push the application from AIR WATCH CONSOLE to my Device. Now, the issue i am facing is, If i am adding some application configuration in the AIR WATCH CONSOLE, i am not able to get those details in my application.

I have gone through the below Url for the above scenario,

https://appconfig.org/android/ which is very much similar to https://appconfig.org/ios/

I have implemented those things that were mentioned in the above url but still then i am not able to get those details.Please let me know if i am wrong anywhere.

I got to know that the key value pairs that were being passed in Air watch console will be coming into com.apple.configuration.managed key in iOS. Does any one have an idea that how these key value pairs will come. As far as i know, they will be handled via Restriction Manager. But no idea/clue how to handle in Android.

Updated:

xml/app_restrictions.xml:

<?xml version="1.0" encoding="utf-8"?>
<restrictions xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <restriction
        android:key="ManagedServer"
        android:restrictionType="string"
        android:title="Managed Server"
        tools:ignore="ValidRestrictions" />

    <restriction
        android:key="@string/mdm_key_managed_server_name"
        android:restrictionType="string"
        android:title="@string/mdm_key_managed_server_url"
        tools:ignore="ValidRestrictions" />
    <restriction
        android:key="@string/mdm_key_managed_server_url"
        android:restrictionType="string"
        android:title="@string/mdm_key_managed_server_url"
        tools:ignore="ValidRestrictions" />

</restrictions>

oncreate Method :

IntentFilter restrictionsFilter =
                new IntentFilter(Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED);

    BroadcastReceiver restrictionsReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {

            // Get the current configuration bundle
            Bundle appRestrictions = myRestrictionsMgr.getApplicationRestrictions();

            // Check current configuration settings, change your app's UI and
            // functionality as necessary.
            Toast.makeText(LoginActivity.this, "Reciever Called", Toast.LENGTH_LONG).show();
            RestrictionsManager myRestrictionsMgr =
                    (RestrictionsManager)
                            getSystemService(Context.RESTRICTIONS_SERVICE);
            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
                if (myRestrictionsMgr != null) {
                    Bundle appRestrictions = myRestrictionsMgr.getApplicationRestrictions();
                    if (appRestrictions != null) {
                        if (appRestrictions.containsKey("ManagedServer")) {
                            String mConfigDetails = appRestrictions.getString("Managed Server");
                            Toast.makeText(LoginActivity.this, "" + mConfigDetails, Toast.LENGTH_LONG).show();
                        }
                    }
                }
            }
        }
    };

    registerReceiver(restrictionsReceiver, restrictionsFilter);

List of Users:

enter image description here

When i am actually trying the other command:

enter image description here

Update:

Created a sample app and published to Play Store. App link as follows,

https://play.google.com/store/apps/details?id=com.manu.samplemdm

Now, its a play store app. When I am sending Application Configuration but unable to receive it in the Application. Its giving me still empty bundle from the application.

Help would be really appreciated.

enter image description here

Help is really appreciated

Eliezer answered 8/2, 2017 at 12:7 Comment(0)
W
2

Beside AirWatch Resources, which tells you how you can create an app and set the app configurations,key-value pairs, to push to your devices, You need to check out Android Restriction Manager API. Follow the steps described in the link.

How the whole process works is, AirWatch controls AndroidForWork environment after you set your MDM as AirWatch. And then, AirWatch manages the device from AirWatch console and it pushes the App Configuration to AndroidForWork in your device. You need to implement Android Restriction Manager to access to these data passed you by your MDM. It goes same for all of the MDMs in the Market.

Update:

In order to install your app into Work Container in the development phase, you can use adb to copy it from Personal Container to Work Container.

First, list all of the active users in the device:

./adb shell pm list users

And later, find the Work User's ID from the List of Users and set it in the command below along with your app's package name and App's Main Activity.

./adb shell am start —user 13 -n “your.apps.package.name/your.main.activity.package.name”

13 up there in the command is the Work User's ID. In my case, it's 13.

For more information about ./adb commands in Managed Profiles, see this link and check the most bottom of the page.

Whizbang answered 20/2, 2017 at 16:26 Comment(23)
I have already implemented Android Restrictions Manager. But, how can i get the key value in my application. Where do i get those. Could you please help me please ? It will be really great, if you have any sample code for this ?Eliezer
@ManoharPerepa if you can share your Android Restriction Manager Implementation, then I can tell you where it gets wrong. Please update your question with your implementation and then ping me.Whizbang
Updated Question and shared code. Please let me know if i am wrong anywhere.. @WhizbangEliezer
I couldn't compare all of your code, but one thing caught my eyes in the first glance. You are only implementing the Broadcast Receiver which is only called when the AirWatch Configuration data is changed. How I do is, I retrieve Application Restrictions in onResume of my MainActivity, without waiting for the Broadcast Receiver. I still have it with the same purpose you have, but it's better to keep both of the implementations.Whizbang
@ManoharPerepa Please give it a try and ping me if it works or not.Whizbang
I have written in onresume too. and checking for Application restrictions. but, all the time my application restrictions are giving me an empty bundle. Could you please help me on thisEliezer
are you trying to access to ApplicationRestrictions directly in onResume ? not with a Broadcast Receiver right ?Whizbang
Another thing to mention is, as far as I see, you are trying to get the "Manager Server" value by it's title, not the "key" as you defined in the XML file. Can you debug your app and check the bundle instance ? to see if it's really wrong key you are providing or it's completely empty ?Whizbang
one more thing to mention is, when you install the app to your device, it's not automatically installed into the work profile, are you sure the app is in the "Work" container, e.g it has the little work icon on the app's icon ?Whizbang
I debugged and checked its empty bundle. I changed that. I am getting that with the key name only. are you sure the app is in the "Work" container? My device is setup with AFW. Could you please guide me in setting the app for AFW please. With a broadcast receiver onlyEliezer
Could you please help me on this ? Please, I am in need of thisEliezer
Hey, Could you please help me on thisEliezer
@ManoharPerepa I'm not sure what is wrong in your setup. I need more information. I'm comparing my implementation with yours but nothing seems like a standing difference. Let's check your <meta-data> from your manifest file. Did you point your restrictions XML file in the Manifest file, under application tag ?Whizbang
My Question is, do i need to set the application for android for work ? if so, please guide me in doing so. Yes, i have written restrictions xml in manifest file. Could you please share your code and example.Eliezer
@ManoharPerepa of course, your app has to be in the WORK Container, which puts little orange 'bag icon' onto your app's icon. see this link, and let me know if your app is in the work container. ssl.gstatic.com/images/branding/product/1x/…Whizbang
No, its not in the work container. How to set my app in the work container. Could you please help me. Even, i am very much new to the Concept of AFW. Is that AFW should enable to device or app. FYI, my device is already set to AFW Profile. But, my application is not displaying as the image you have providedEliezer
@ManoharPerepa So you have two options; 1- if you release the app in Google Play and AirWatch Admin whitelists the application for "Google Play for Work" you can download it directly from the Google Play App in the Work Container. Since you are still developing the app, this will be for later on. Now, after you install the app in the device, you can copy your app to the work container with ADB.Whizbang
Please find the attached screens in the updated question. Please correct me if i am wrong.Eliezer
@ManoharPerepa you are running the wrong user. see my edited answer for adb command reference. You are using '0' as user ID which should be 10 instead. And make sure the rest of the command is typed correctly.Whizbang
Hey, @osayilgan, I am really in help of this. Can i have your personal mail id or any other means of contact regarding this implementation.Eliezer
@ManoharPerepa Go ahead and join the chat room I've created. Hope I will get notifications. chat.stackoverflow.com/rooms/info/138263/airwatchWhizbang
Wondering if the issue got resolved yet? We are using ionic cordova and we are having the same issue with the restriction.xml. We are trying to get the EnrollmentUser name, but we just got an empty object instead... For IOS, it works without any issue. We called airwatch, but they doesn't support any sample code..Bartolemo
@GeorgeHuang did you define the User Name inside restriction.xml ? If you did, this is the first part of the configuration. You need to go to your MDM Provider's dashboard, whether it's airwatch or something else, and make sure you are providing the same key-value pairs there as well.Whizbang
R
1

There are a couple of different approaches to integrating with AirWatch. It depends on the technology set you're trying to use. I think these are the 2 that are most relevant to you based on what I see in your post:

  1. AirWatch SDK
  2. AppConfig Standard

Both these approaches can accomplish similar functionality but each have different deployment requirements. It sounds like you have gone with the second approach which is using the AppConfig standard and the native APIs provided by Google to have an app read configuration values delivered through AirWatch.

One important thing to note is the AppConfig standard approach on Android requires the device to support "Android for Work" enrollment which is a relatively newer management protocol released by Google. It's worth noting that AirWatch does support Android for Work enrollment so it may just be a matter of getting your AirWatch test instance configured for "Android for Work enrollment" instead of the traditional older Android enrollment protocol. More information about Android for Work can be found here: https://enterprise.google.com/android/solutions/personal/

If you're already a customer of AirWatch, it may be helpful to create an account here on their resource portal if you haven't done so already to get access to documentation about how you can setup Android for Work within AirWatch. https://resources.air-watch.com

I hope this helps.

Rameses answered 16/2, 2017 at 21:15 Comment(3)
resources.air-watch.com. Link is not working after logging in. And my device is already enrolled for Android for Work. Now, could you please let me know if i need to send some settings from Air watch console to the applciationEliezer
All i need is, While i am adding application in the Air watch console, i am adding some application configuration details in the console. how can i get those details that were added in the console to the android application.Eliezer
iOS dev are able to get the settings via com.apple.configuration.managed key. Is there any way that android dev can get that information.Eliezer

© 2022 - 2024 — McMap. All rights reserved.