Add a device administrator application to Android 

Joined:
07/27/2010
Posts:
128

June 09, 2011 15:52:12    Last update: June 09, 2011 15:52:30
Follow these steps to add a device administrator application to Android, i.e., make the application appear in the "Select device administrators" screen (Settings -> Location & Security -> Select device administrators):
  1. Add a receiver in AndroidManifest.xml:
    <receiver android:name="android.app.admin.DeviceAdminReceiver"
        android:label="@string/admin_app"
        android:description="@string/admin_app_description"
        android:permission="android.permission.BIND_DEVICE_ADMIN">
        <meta-data android:name="android.app.device_admin"	android:resource="@xml/admin_app_config"/>
        <intent-filter>
        	<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
        </intent-filter>
    </receiver>
    

    All elements and attributes listed above are needed. The attribute android:description must be a string resource, not a literal string. The meta-data element points to an XML resource.
  2. Create the meta-data resource res/xml/admin_app_resource.xml:
    <device-admin xmlns:android="http://schemas.android.com/apk/res/android">
        <uses-policies>
            <limit-password/>
            <watch-login/>
            <reset-password/>
            <force-lock/>
            <wipe-data/>
        </uses-policies>
    </device-admin>
    

  3. Define values for string resources (res/values/strings.xml):
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <string name="admin_app">Admin App Demo</string>
        <string name="admin_app_description">More detailed description of the admin app</string>
    </resources>
    

Share |
| Comment  | Tags