The final intention is to have the device in kiosk mode.
They tell you you do not need NFC or rooting in order for the application to become the owner of the device . I have not seen a complete example of this method yet, but I will try:
adb shell dpm set-device-owner <package>/.<ReceiverImplementation>
should do ... so I do this and get:
java.lang.SecurityException: Neither user 2000 nor current process has android.permission.BIND_DEVICE_ADMIN.
Thus, the following code returns false.
((DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE)) .isDeviceOwnerApp(getApplicationContext().getPackageName())
This STO question poses a similar question, but does not indicate an actual failure.
The manifest file and the rest of the source are mostly inspired by 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>
The device I'm trying to make at the moment is the LG G Pad.
source share