Working with requests for different profiles: Android for Work

For some technical reasons, I cannot use the Android File Picker to get the file and their contents in my application. This is why I came up with a solution that requests intent and processes the results in my own interface.

Here is how I get a list of applications with Intent.ACTION_GET_CONTENT

/* Create a new Intent to Read a File */
Intent documentIntent = new Intent(Intent.ACTION_GET_CONTENT);
documentIntent.setType((action == ACTION_SELECT_FILE) ? "*/*" : "image/*");

/* Query for Applications to see which are available */
List<ResolveInfo> appList = getActivity().getPackageManager().queryIntentActivities(documentIntent, PackageManager.MATCH_DEFAULT_ONLY);

This works great and lists applications that can handle my request.

But I work with Android for Work , and when I execute the above code, I get a list of applications available for the Work Profile , which is expected.

But one of the results that comes back from the above code is “Switch to personal” , which lists the applications installed in the Personal account in Android File Picker .

So the question is, how can I get the same behavior? How can I request actions for a specific action?

+4
source share
1 answer

I don't have a big idea about Android for Work , but it is mentioned in the Developer's Guide , which

The Android system prevents profiles from crossing, and IT administrators can enable or disable system applications.

, / Activity , , .

fooobar.com/questions/1575687/..., Device Policy Controller, DevicePolicyManager#clearCrossProfileIntentFilters(ComponentName admin) .

- , , Content URIs File URIs . .

+1

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


All Articles