简体   繁体   中英

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.

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 TV 中将应用设置为设备所有者。

Format your Android TV Box. Enable your developer option in Android TV Box Connect your Terminal with the IP address with command adb connect 192.168.X.XX

Install the apk Run below command to adb shell dpm set-device-owner /.DevAdminReceiver

Steps to set-device-owner through cmd,

  1. Connect your device with USB debugging mode.
  2. Set directory using cd command to ...Sdk\\platform-tools
  3. Write adb shell and hit enter
  4. You will see shell@degas3g:/ $ in cmd
  5. Now write dpm set-device-owner com.android.testapp/.receivers.AdminReceiver and hit enter
  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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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