T
T
TechNOIR2019-07-08 23:29:56
Android
TechNOIR, 2019-07-08 23:29:56

android tv. How to get DEVICE_ADMIN rights to lock a device?

Good afternoon.
There is a small timer application that sends the device to sleep / blocks after the time has elapsed.
On the Pixel phone emulator, everything works ok. At startup, administrator rights are requested, etc.
But on the Android TV emulator, as well as on the live set-top box itself, nothing is requested. You can once the screen is white and that's it. The application essentially starts and crashes.
Perhaps on Android TV rights are issued somehow differently?
Thanks in advance.
I am attaching the manifest from the project. But if you need anything else, I'll provide it.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.infnitum.sleeptimer">

    <uses-feature android:name="android.software.leanback"
                  android:required="false" />
    <uses-feature android:name="android.hardware.touchscreen"
                  android:required="false" />

    <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher_foreground"
            android:label="@string/app_name"
            android:supportsRtl="true"
            android:theme="@style/AppTheme">
        <activity android:name=".TimerActivity"
        android:screenOrientation="landscape"
        >

        </activity>
        <activity
                android:name=".MainActivity"
                android:banner="@drawable/clock"
                android:icon="@drawable/clock"
                android:label="@string/app_name"
                android:logo="@drawable/clock"
                android:screenOrientation="landscape">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <action android:name="android.app.action.ADD_DEVICE_ADMIN" />
                <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
                <category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
            </intent-filter>
        </activity>


        <receiver
                android:name=".MyAdmin"
                android:permission="android.permission.BIND_DEVICE_ADMIN">
            <meta-data
                    android:name="android.app.device_admin"
                    android:resource="@xml/policies"/>

            <intent-filter>

                <action android:name="android.app.action.DEVICE_ADMIN_ENABLED"/>
            </intent-filter>
        </receiver>
    </application>

</manifest>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question