【发布时间】:2015-07-01 14:21:24
【问题描述】:
这里的最终目的是在“kiosk mod”中拥有一个设备。
Theysay你不需要NFC也不需要root来实现应用程序变成device owner。我还没有看到这种方法的完整示例,但让我们尝试一下:
adb shell dpm set-device-owner <package>/.<ReceiverImplementation>
应该这样做...所以我这样做了,然后得到:
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 提出了类似的问题,但没有指定实际失败..
Manifest 文件和其余的源代码大部分灵感来自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>
我目前正在尝试执行此操作的设备是 LG G Pad。
【问题讨论】:
-
澄清一下...您的接收器在清单中有 android.permission.BIND_DEVICE_ADMIN 但您仍然遇到此异常?
-
是的,我将编辑问题以显示这一点。
-
还有一个问题。您的 device_owner_receiver.xml 文件中有什么内容?
-
没有改变那个
-
android 文档状态:
To deploy and activate a device owner, you must perform an NFC data transfer...@developer.android.com/about/versions/…
标签: android android-5.0-lollipop kiosk-mode