我正在使用Android MDM,并在/ src / main / res / xml /文件夹下有app_restrictions.xml文件。我使用的MDM没有向我显示限制的值,甚至没有显示默认值。已按照此链接中提及的所有步骤设置应用限制:https://developer.android.com/training/enterprise/app-restrictions.html 但我得到了Bundle [EMPTY_PARCEL]。下面是代码
app_restrictions.xml
<?xml version="1.0" encoding="utf-8"?>
<restrictions xmlns:android="http://schemas.android.com/apk/res/android">
<restriction
android:key="MDMEmailKey"
android:title="Email"
android:restrictionType="string"
android:description="@string/email_address_mdm_description"
android:defaultValue="testtesttest@gmail.com" />
<restriction/>
</restrictions>
此外,lint向我显示错误,但我能够通过lint选项在gradle中抑制它,但只是想知道它是不是我面临的问题的原因。请让我知道为什么我会收到这些错误。
Executing task ':project_name:lintVitalRelease' (up-to-date check took 0.0 secs) due to:
Task has not declared any outputs.
.../src/main/res/xml/app_restrictions.xml:8: Error: Missing required attribute android:key [ValidRestrictions]
<restriction/>
~~~~~~~~~~~~~~
.../src/main/res/xml/app_restrictions.xml:8: Error: Missing required attribute android:restrictionType [ValidRestrictions]
<restriction/>
~~~~~~~~~~~~~~
.../src/main/res/xml/app_restrictions.xml:8: Error: Missing required attribute android:title [ValidRestrictions]
<restriction/>
~~~~~~~~~~~~~~
Explanation for issues of type "ValidRestrictions":
Ensures that an applications restrictions XML file is properly formed
https://developer.android.com/reference/android/content/RestrictionsManager.html
3 errors, 0 warnings
答案 0 :(得分:0)
RE:lint错误
您在第8行restriction
处有一个空的<restriction/>
元素
只需删除它,皮棉错误就会消失。
<?xml version="1.0" encoding="utf-8"?>
<restrictions xmlns:android="http://schemas.android.com/apk/res/android">
<restriction
android:key="MDMEmailKey"
android:title="Email"
android:restrictionType="string"
android:description="@string/email_address_mdm_description"
android:defaultValue="testtesttest@gmail.com" />
<restriction/> <!-- Error here -->
</restrictions>