Final intention here is to have a device in 'kiosk mod'.
They say you don't need NFC nor rooting to achieve application becoming device owner. I've yet to see a full example of this method but lets try:
adb shell dpm set-device-owner <package>/.<ReceiverImplementation>
should do... So I do so, and get:
java.lang.SecurityException:
Neither user 2000 nor current process has android.permission.BIND_DEVICE_ADMIN.
Following code, therefore, returns false.
((DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE))
.isDeviceOwnerApp(getApplicationContext().getPackageName())
This STO question poses a similar question but doesn't specify an actual failure..
Manifest file and the rest of the source is mostly inspired from this google sample
<manifest
package="com.example.android.deviceowner"
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0">
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<receiver
android:name=".DeviceOwnerReceiver"
android:description="@string/app_name"
android:label="@string/app_name"
android:permission="android.permission.BIND_DEVICE_ADMIN">
<meta-data
android:name="android.app.device_admin"
android:resource="@xml/device_owner_receiver"/>
<intent-filter>
<action android:name="android.app.action.ACTION_DEVICE_ADMIN_ENABLED"/>
</intent-filter>
</receiver>
</application>
</manifest>
Device I am trying to do this currently is LG G Pad.
Your manifest file seems correct.
You should be aware that it may come from the state of your system when you are executing this command. Many points should be checked before running the dpm
command successfully :
The best thing to do (That's what I did when experimenting indeed) is to completely factory-reboot your phone and avoid most configuration steps (except the mandatories steps "configure Wi-Fi", and "Name"), and do not associate any Google account.
Once provisioned, you are sure to be in a clean state.
Then,
pm install
...)adb shell dpm set-device-owner ...
I've written an article explaining most of these steps on my blog, take a look at it, it may be useful in your case.