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

1

10

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.

Debus answered 20/10, 2016 at 8:6 Comment(1)
Assuming that work profile has some restrictions, at least one, use UserManager to check if the current profile has restrictions.Ballplayer
L
4

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");
    }
Long answered 31/10, 2016 at 15:32 Comment(3)
Hi, @Long and thanks for the answer. The problem is that if admin did not set-up the value - you will receive false although the application is under managed profile. This answer is half right, you can definitely say that you are under managed profile if you are getting true, but if you are getting false you may end up with false negative.Debus
Probably you should ask admin to do things that way? It's just not clear from your question that you don't have access to administration.Long
I'm only providing the app. There may be several different EMM on the server-side and many adminsDebus

© 2022 - 2024 — McMap. All rights reserved.