Android的 - 如何接收广播意图ACTION_SCREEN_ON / OFF? [英] Android - how to receive broadcast intents ACTION_SCREEN_ON/OFF?

查看:997
本文介绍了Android的 - 如何接收广播意图ACTION_SCREEN_ON / OFF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    <application>
         <receiver android:name=".MyBroadcastReceiver" android:enabled="true">
                <intent-filter>
                      <action android:name="android.intent.action.ACTION_SCREEN_ON"></action>
                      <action android:name="android.intent.action.ACTION_SCREEN_OFF"></action>
                </intent-filter>
         </receiver>
...
    </application>

MyBroadcastReceiver 设置只是吐FOO的日志。什么都不做。 有什么建议吗?我是否需要指定任何权限赶上意图是什么?

MyBroadcastReceiver is set just to spit foo to the logs. Does nothing. Any suggestions please? Do I need to assign any permissions to catch the intent?

推荐答案

我认为,这些行为只能通过在Java中code(注册接收机通过 registerReceiver()接受),而不是通过在清单中注册的接收器。

I believe that those actions can only be received by receivers registered in Java code (via registerReceiver()) rather than through receivers registered in the manifest.

这篇关于Android的 - 如何接收广播意图ACTION_SCREEN_ON / OFF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆