这里的最终目的是在’kiosk mod’中设置一个设备.
They say您不需要NFC也不需要生根来实现应用程序成为device owner.我还没有看到这个方法的完整示例但是让我们试试:
adb shell dpm set-device-owner /.
应该这样做…所以我这样做,并得到:
java.lang.SecurityException:
Neither user 2000 nor current process has android.permission.BIND_DEVICE_ADMIN.
因此,以下代码返回false.
((DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE))
.isDeviceOwnerApp(getApplicationContext().getPackageName())
This STO question提出了类似的问题,但未指明实际的失败.
package="com.example.android.deviceowner"
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0">
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
android:name=".MainActivity"
android:label="@string/app_name">
android:name=".DeviceOwnerReceiver"
android:description="@string/app_name"
android:label="@string/app_name"
android:permission="android.permission.BIND_DEVICE_ADMIN">
android:name="android.app.device_admin"
android:resource="@xml/device_owner_receiver"/>
我试图这样做的设备目前是LG G Pad.