README.md
1
2 Android AppRestrictionSchema Sample
3 ===================================
4
5 A basic app showing how to allow a device administrator to restrict user
6 activities using the Android Device Administration API. The app exports
7 a custom policy that enables or disables a UI control. Device Administration
8 applications are able to enforce a specific value for this policy, as
9 directed by enterprise administrators.
10
11 Introduction
12 ------------
13
14 The [Android Device Administration API][1] allows enterprise administrators to
15 enforce specific policies on a managed device. The system provides policies
16 that control settings such as password complexity, screen lock, or camera
17 availability. Developers can also augment this list with custom policies
18 that control specific features within their applications. For example,
19 a web browser could provide access to a whitelist of allowed domains.
20
21 The list of policies exposed by an app must be specified using a file
22 inside of the `res/xml` directory, using the `<restriction>` tag:
23
24 ```xml
25 <restrictions xmlns:android="http://schemas.android.com/apk/res/android">
26
27 <restriction
28 android:defaultValue="false"
29 android:description="@string/description_can_say_hello"
30 android:key="can_say_hello"
31 android:restrictionType="bool"
32 android:title="@string/title_can_say_hello" />
33
34 </restrictions>
35 ```
36
37 In this sample, that file can be found at
38 `Application/src/main/res/xml/app_restrictions.xml`. This file must be
39 also be declared inside of `ApplicationManifest.xml` using a `<meta-data>`
40 element:
41
42 ```xml
43 <meta-data
44 android:name="android.content.APP_RESTRICTIONS"
45 android:resource="@xml/app_restrictions" />
46 ```
47
48 At runtime, the current list of restrictions enforced by policy can be
49 checked by calling [RestrictionsManager.getApplicationRestrictions()][2].
50
51 [1]: http://developer.android.com/guide/topics/admin/device-admin.html
52 [2]: https://developer.android.com/reference/android/content/RestrictionsManager.html#getApplicationRestrictions()
53
54 Pre-requisites
55 --------------
56
57 - Android SDK 23
58 - Android Build Tools v23.0.3
59 - Android Support Repository
60
61 Screenshots
62 -------------
63
64 <img src="screenshots/main.png" height="400" alt="Screenshot"/>
65
66 Getting Started
67 ---------------
68
69 This sample uses the Gradle build system. To build this project, use the
70 "gradlew build" command or use "Import Project" in Android Studio.
71
72 Support
73 -------
74
75 - Google+ Community: https://plus.google.com/communities/105153134372062985968
76 - Stack Overflow: http://stackoverflow.com/questions/tagged/android
77
78 If you've found an error in this sample, please file an issue:
79 https://github.com/googlesamples/android-AppRestrictionSchema
80
81 Patches are encouraged, and may be submitted by forking this project and
82 submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
83
84 License
85 -------
86
87 Copyright 2016 The Android Open Source Project, Inc.
88
89 Licensed to the Apache Software Foundation (ASF) under one or more contributor
90 license agreements. See the NOTICE file distributed with this work for
91 additional information regarding copyright ownership. The ASF licenses this
92 file to you under the Apache License, Version 2.0 (the "License"); you may not
93 use this file except in compliance with the License. You may obtain a copy of
94 the License at
95
96 http://www.apache.org/licenses/LICENSE-2.0
97
98 Unless required by applicable law or agreed to in writing, software
99 distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
100 WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
101 License for the specific language governing permissions and limitations under
102 the License.
103