Android notification of screen off/on

前端 未结 3 395
别那么骄傲
别那么骄傲 2020-12-10 02:17

I\'m looking to see if there\'s a system notification I can listen for to see when the screen turns off/on. Any thoughts? Something similar to when the network connects/di

3条回答
  •  情书的邮戳
    2020-12-10 02:41

    The system will broadcast when the screen turns on and off -

    In order to listen for these, you can create a BroadcastReceiver that listens for the events:

    Intent.ACTION_SCREEN_OFF
    Intent.ACTION_SCREEN_ON
    

    They're listed in the documentation here:

    Also, there's a tutorial about responding to these events that you might find useful.

提交回复
热议问题