1 <?xml version="1.0" encoding="UTF-8"?> 2 <!-- 3 Copyright 2014 The Android Open Source Project 4 5 Licensed under the Apache License, Version 2.0 (the "License"); 6 you may not use this file except in compliance with the License. 7 You may obtain a copy of the License at 8 9 http://www.apache.org/licenses/LICENSE-2.0 10 11 Unless required by applicable law or agreed to in writing, software 12 distributed under the License is distributed on an "AS IS" BASIS, 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 See the License for the specific language governing permissions and 15 limitations under the License. 16 --> 17 18 <sample> 19 <name>AppRestrictionSchema</name> 20 <group>Admin</group> 21 <package>com.example.android.apprestrictionschema</package> 22 23 <minSdk>21</minSdk> 24 <compileSdkVersion>21</compileSdkVersion> 25 26 <strings> 27 <intro> 28 <![CDATA[ 29 This sample shows how to use app restrictions. This application has one boolean 30 restriction with a key \"can_say_hello\" that defines whether the only feature of this 31 app (press the button to show \"Hello\" message) is enabled or disabled. Use 32 AppRestrictionEnforcer sample to toggle the restriction. 33 ]]> 34 </intro> 35 </strings> 36 37 <template src="base" /> 38 <template src="FragmentView" /> 39 <common src="logger" /> 40 <common src="activities" /> 41 42 <metadata> 43 <status>PUBLISHED</status> 44 <categories>Device Admin</categories> 45 <technologies>Android</technologies> 46 <languages>Java</languages> 47 <solutions>Mobile</solutions> 48 <level>ADVANCED</level> 49 <icon>Application/main/big_icon.png</icon> 50 <screenshots> 51 <img>screenshots/main.png</img> 52 </screenshots> 53 <api_refs> 54 <android>android.content.RestrictionsManager</android> 55 </api_refs> 56 57 <description> 58 A basic app showing how to allow a device administrator to restrict user 59 activities using the Android Device Administration API. The app exports 60 a custom policy that enables or disables a UI control. Device Administration 61 applications are able to enforce a specific value for this policy, as 62 directed by enterprise administrators. 63 </description> 64 65 <intro> 66 <![CDATA[ 67 The [Android Device Administration API][1] allows enterprise administrators to 68 enforce specific policies on a managed device. The system provides policies 69 that control settings such as password complexity, screen lock, or camera 70 availability. Developers can also augment this list with custom policies 71 that control specific features within their applications. For example, 72 a web browser could provide access to a whitelist of allowed domains. 73 74 The list of policies exposed by an app must be specified using a file 75 inside of the `res/xml` directory, using the `<restriction>` tag: 76 77 ```xml 78 <restrictions xmlns:android="http://schemas.android.com/apk/res/android"> 79 80 <restriction 81 android:defaultValue="false" 82 android:description="@string/description_can_say_hello" 83 android:key="can_say_hello" 84 android:restrictionType="bool" 85 android:title="@string/title_can_say_hello" /> 86 87 </restrictions> 88 ``` 89 90 In this sample, that file can be found at 91 `Application/src/main/res/xml/app_restrictions.xml`. This file must be 92 also be declared inside of `ApplicationManifest.xml` using a `<meta-data>` 93 element: 94 95 ```xml 96 <meta-data 97 android:name="android.content.APP_RESTRICTIONS" 98 android:resource="@xml/app_restrictions" /> 99 ``` 100 101 At runtime, the current list of restrictions enforced by policy can be 102 checked by calling [RestrictionsManager.getApplicationRestrictions()][2]. 103 104 [1]: http://developer.android.com/guide/topics/admin/device-admin.html 105 [2]: https://developer.android.com/reference/android/content/RestrictionsManager.html#getApplicationRestrictions() 106 ]]> 107 </intro> 108 </metadata> 109 110 </sample> 111