Determine that you are working with an Android for Work container?

How to determine if my application is running from Android for a working container?

+4
source share
1 answer

Use the following:

int userId = Process.myUid()/100000;

userId will contain ints that represent the current identifier of the user in which the application is running.

For example:

  • In case the application is run under the "owner" of the device, userId will be 0.
  • In case the application runs under the user owner profile, userId will be 10.

If your application is compiled as part of the Android platform and it has access to hidden APIs, use the following:

int userId = UserHandle.myUserId()
0
source

Source: https://habr.com/ru/post/1626036/


All Articles