简体   繁体   English

如何在Android TV上接收BOOT_COMPLETED

[英]How to receive BOOT_COMPLETED on Android TV

I'm developing an app for Android TV. 我正在为Android TV开发应用程序。 I have a sticky service & a broadcast receiver that should restart this service after system reboot. 我有一个粘性服务和广播接收器,应该在系统重启后重新启动此服务。

The code works perfect for any phone, but, in the case of the TV, any of the actions that I defined in the receiver's intent isn't received, when turning on the TV from standby(using the remote). 该代码适用于任何手机,但是,在电视的情况下,当从待机状态打开电视时(使用遥控器),我没有收到我在接收器意图中定义的任何动作。 It works when I unplug the TV and plug it again. 当我拔下电视并重新插上电视时,它可以正常工作。

Has anyone tried something similiar? 有没有人尝试过类似的东西? Any advice might help. 任何建议可能会有所帮 Thanks 谢谢

I've tried BOOT_COMPLETED , QUICKBOOT_POWERON , REBOOT , ACTION_POWER_CONNECTED . 我试过BOOT_COMPLETEDQUICKBOOT_POWERONREBOOTACTION_POWER_CONNECTED

Here is the receiver I've configured. 这是我配置的接收器。

<receiver
        android:name=".MyReceiver"
        android:directBootAware="true"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" 
/>
            <action 
android:name="android.intent.action.QUICKBOOT_POWERON" />
            <action android:name="android.intent.action.REBOOT" />
            <action 
android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
            <action 
android:name="android.intent.action.ACTION_POWER_CONNECTED" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </receiver>

Expected to catch the action of turning on the device in the broadcast. 期望抓住在广播中打开设备的动作。

请检查您是否添加了以下权限。

uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"

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

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