Note that there are some explanatory texts on larger screens.

plurals
  1. POdevice policy administration errors with Android
    primarykey
    data
    text
    <p>I recently started exploring the android device policy administration APIs and have run into a bit of a wall. i'm having problems simply enabling the device administration. I'm fairly certain it is a problem with the manifest entry, however I can't quite pinpoint the problem area.</p> <p>Manifest entry:</p> <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example" android:versionCode="1" android:versionName="1.0"&gt; &lt;application android:label="DeviceAdminTrial" android:icon="@drawable/icon" android:debuggable="true"&gt; &lt;activity android:name=".MyActivity" android:label="@string/app_name"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;receiver android:name=".Receiver" android:label="device_admin" android:permission="android.permission.BIND_DEVICE_ADMIN"/&gt; &lt;meta-data android:name="android.app.device_admin" android:resource="@xml/device_admin" /&gt; &lt;intent-filter&gt; &lt;action android:name="android.app.action.DEVICE_ADMIN_ENABLED"/&gt; &lt;/intent-filter&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>Error message:</p> <pre><code>12-25 15:42:38.930: WARN/DeviceAdminAdd(394): Unable to retrieve device policy ComponentInfo{com.example/com.example.Receiver} org.xmlpull.v1.XmlPullParserException: No android.app.device_admin meta-data </code></pre> <p>device_admin.xml</p> <pre><code>&lt;device-admin xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;uses-policies&gt; &lt;limit-password /&gt; &lt;watch-login /&gt; &lt;reset-password /&gt; &lt;force-lock /&gt; &lt;wipe-data /&gt; &lt;/uses-policies&gt; &lt;/device-admin&gt; </code></pre> <p>Enabling Method:</p> <pre><code> enable = (Button)findViewById(R.id.button); enable.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent intent = new Intent (DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN); intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, receiver); startActivityForResult(intent, 1);//1 is enabled, 0 is disabled. output.setText(""+policymanager.isAdminActive(receiver)); } }); </code></pre> <p>And the Receiver class is as basic as the sample found here: <a href="http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/DeviceAdminSample.html" rel="noreferrer">http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/DeviceAdminSample.html</a></p> <p>any help or advice would be much appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload