0

I am working on Android MDM and have the app_restrictions.xml file under /src/main/res/xml/ folder. The MDM I am using is not showing me the value of the restriction, not even the default value. All the steps mentioned in this link has been followed to set app restrictions: https://developer.android.com/training/enterprise/app-restrictions.html but i am getting Bundle[EMPTY_PARCEL]. below is the code

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>

Also, the lint is showing me below errors, though I was able to suppress it in gradle through lint options, but just wondering if it is not the cause of the issue I am facing. Please let me know why I am getting these errors.

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
Surbhi
  • 33
  • 1
  • 7
  • Did you successfully implemented MDM in your application. Could you please check this ? Could you please help me on the following.. Help is really appreciated http://stackoverflow.com/questions/42112688/integrating-air-watch-android-studio – Manu Feb 16 '17 at 09:00

1 Answers1

0

RE: The lint errors You have an empty restriction element at line 8 <restriction/> Just remove it and the lint errors will go away.

<?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>
Nagesh Susarla
  • 1,660
  • 10
  • 10
  • Thanks Nagesh, this solved the lint errors, but you have any idea about why i am getting empty parcel at Bundle appRestrictions = myRestrictionsMgr.getApplicationRestrictions();, even if i have downloaded my app via MDM. – Surbhi Feb 08 '16 at 08:03
  • Is this giving an exception? Also can you please try the sample app listed at https://developer.android.com/samples/AppRestrictionSchema/AndroidManifest.html – Nagesh Susarla Feb 08 '16 at 18:35