MDM Engine enables in-depth management of Huawei devices for authorized apps.

Contents to be implemented by Codelab

In this codelab, you will create a demo project, integrate the MDM Engine SDK into the project, and call the APIs provided by MDM Engine to implement security management on the mobile device and apps.

What Will You Learn

In this codelab, you will learn how to:

Hardware Requirements

Software Requirements

Required Knowledge

The MDM APIs can be used only after permissions are granted. For details about the authorization, please refer to Preparations.

1. Import MDM Engine to the project.

2. Call the APIs of MDM Engine.

For example, the following example shows how to call the APIs for disabling Wi-Fi and screenshot.

private class SampleOnClickListener implements OnClickListener { @Override public void onClick(View view) { try { switch (view.getId()) { case R.id.disableWifi: mDeviceRestrictionManager.setWifiDisabled(mAdminName, true); break; case R.id.enableWifi: mDeviceRestrictionManager.setWifiDisabled(mAdminName, false); break; case R.id.disableScreenCapture: mDeviceRestrictionManager.setScreenCaptureDisabled(mAdminName, true); break; case R.id.enableScreenCapture: mDeviceRestrictionManager.setScreenCaptureDisabled(mAdminName, false); break; ...... default: break; } } catch (NoSuchMethodError error) { Toast.makeText(getApplicationContext(), getString(R.string.not_support), Toast.LENGTH_SHORT).show(); } catch (SecurityException securityException) { Toast.makeText(getApplicationContext(), getString(R.string.no_permission), Toast.LENGTH_SHORT).show(); } updateState(); }

3. Add the permission to use the APIs of MDM Engine to the AndroidManifest.xml file.

For example, add the permissions required for the MDM Engine APIs called in the preceding steps.

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.huawei.mdm.sample"> <uses-permission android:name="com.huawei.permission.sec.MDM" /> <uses-permission android:name="com.huawei.permission.sec.MDM_WIFI" /> <uses-permission android:name="com.huawei.permission.sec.MDM_CAPTURE_SCREEN" /> ...... </manifest>

4. Build the project.

5. Apply for authorization.

For details, please refer to Preparations.

6. Run the APK.

After the authorized APK is installed on the Huawei device, you can view the running results.

Well done. You have successfully completed this codelab and learned how to:

For more information, please click the following link:
Sample Code

Code copied