<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 吐到日志中。什么也没做。
请问有什么建议吗?我是否需要分配任何权限才能捕获 Intent ?
最佳答案
我相信这些 Action 只能由在 Java 代码中注册的接收者(通过 registerReceiver()
)接收,而不是通过在 list 中注册的接收者。
关于Android - 如何接收广播 Intent ACTION_SCREEN_ON/OFF?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1588061/