According to the restriction entry types, for defining a list of objects we should use the bundle_array
type, and an example follows:
<?xml version="1.0" encoding="utf-8"?>
<restrictions xmlns:android="http://schemas.android.com/apk/res/android" >
<restriction
android:key="vpn_configuration_list"
android:restrictionType="bundle_array">
<restriction
android:key="vpn_configuration"
android:restrictionType="bundle">
<restriction
android:key="vpn_server"
android:restrictionType="string"/>
<restriction
android:key="vpn_username"
android:restrictionType="string"/>
<restriction
android:key="vpn_password"
android:restrictionType="string"/>
</restriction>
</restriction>
</restrictions>
In code that would be similar to a List<VpnConfiguration>
, and VpnConfiguration
would be a pojo with the three fields vpn_server
, vpn_username
, and vpn_password
.
So far so good, now imagine that a simpler data structure is needed, like a String[]
.
According to Test DPC this should be possible, because there's an option to insert an array of strings:
Once you select it, then you are prompted to enter the list of values. However, the documentation does not have a string_array
type, it has only the bundle_array
.
With bundle_array
you can define a List<String>
instead of String[]
, but that is overkill:
<restriction
android:key="mylist"
android:restrictionType="bundle_array">
<restriction
android:key="item"
android:restrictionType="bundle">
<restriction
android:key="name"
android:restrictionType="string" />
</restriction>
</restriction>
So, is there a simpler way one can define a string array?
The String[]
value type is only returned for the multi-select
restriction type, for which the EMM returns a set of entries chosen among the ones you define in android:entryValues
.
If you want to allow enterprise admin to enter a list of free-form strings then you should indeed define a bundle_array
that contains a string
restriction.
Edit: Note that bundle_array
is only available on Android 6.0+, and there is no standard way to pass a list of free-form strings on Android 5.0/5.1. You could imagine passing a JSON within a string
but you would need to agree with the EMM on the format of this JSON, so it wouldn't be automatically available with all EMMs.