简体   繁体   English

Android TV Box 上的设备所有者无法正常工作

[英]Device owner on Android TV Box not working

I want to install my application as device owner on Android TV Box and I get the next exception.我想在 Android TV Box 上以设备所有者的身份安装我的应用程序,但出现下一个异常。

adb shell dpm set-device-owner 
"com.android.testapp/.receivers.AdminReceiver"
java.lang.RuntimeException: Can't set package com.android.testapp as 
device owner.
    at com.android.commands.dpm.Dpm.runSetDeviceOwner(Dpm.java:115)
    at com.android.commands.dpm.Dpm.onRun(Dpm.java:82)
    at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
    at com.android.commands.dpm.Dpm.main(Dpm.java:38)
    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:251) 

There are no accounts on the device.设备上没有帐户。 It works on my phones but not on the Android TV Box.它适用于我的手机,但不适用于 Android 电视盒。

遗憾的是,无法在 Android TV 中将应用设置为设备所有者。

Format your Android TV Box.格式化您的 Android 电视盒。 Enable your developer option in Android TV Box Connect your Terminal with the IP address with command adb connect 192.168.X.XX在 Android TV Box 中启用您的开发者选项 使用命令 adb connect 192.168.X.XX 将您的终端与 IP 地址连接起来

Install the apk Run below command to adb shell dpm set-device-owner /.DevAdminReceiver安装 apk 运行下面的命令到 adb shell dpm set-device-owner /.DevAdminReceiver

Steps to set-device-owner through cmd,通过cmd set-device-owner步骤,

  1. Connect your device with USB debugging mode.使用 USB 调试模式连接您的设备。
  2. Set directory using cd command to ...Sdk\\platform-tools使用cd命令将目录设置为...Sdk\\platform-tools
  3. Write adb shell and hit enter编写adb shell并按 Enter
  4. You will see shell@degas3g:/ $ in cmd您将在 cmd 中看到shell@degas3g:/ $
  5. Now write dpm set-device-owner com.android.testapp/.receivers.AdminReceiver and hit enter现在写dpm set-device-owner com.android.testapp/.receivers.AdminReceiver并按回车
  6. Your app will become Device Owner.您的应用将成为设备所有者。

For more information Click Here有关更多信息,请单击此处

EDITED已编辑

Receiver must be like this.接收器必须是这样的。

<receiver
    android:name=".receiver.Receiver"
    android:permission="android.permission.BIND_DEVICE_ADMIN">
    <meta-data
        android:name="android.app.device_admin"
        android:resource="@xml/device_admin" />
    <intent-filter>
        <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
    </intent-filter>
</receiver>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM