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.