Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to distinguish android application running under managed profile and regular profile?

Tags:

android

mdm

Android 5.0 (API level 21) allows enterprises to set up managed profiles. If a device has a managed profile, the profile's settings are under the control of the enterprise administrator. The administrator can choose which apps are allowed for that profile, and can control just what device features are available to the profile.

Suppose we have an application in Google Play Market and also some of the customers are able to install the application via Mobile Device Management Profile. How to distinguish programmatically between those application versions? In other words, how to ensure that specific application version is managed by enterprise administrator (located under work profile) ? Thanks in advance.

like image 560
Evgeniy Mishustin Avatar asked Oct 20 '16 08:10

Evgeniy Mishustin


1 Answers

You can try something like:

    final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
    if (um.hasUserRestriction("WORK_PROFILE_RESTRICTION")) {
        System.out.print("it is work profile");
    } else {
        System.out.print("it isn't work profile");
    }
like image 70
Divers Avatar answered Oct 18 '22 23:10

Divers