How can I programmatically open/close notifications in Android?

前端 未结 7 2462
无人及你
无人及你 2020-12-04 09:51

I\'ve searched everywhere, but can\'t find anything in the SDK or on Google on how to do this. I know it\'s possible because all the custom launchers are able to do it via a

7条回答
  •  一生所求
    2020-12-04 10:30

    Christopher Orr's answer works great for closing the notification drawer.

    You can use AccessibilityServices to programmatically show the notifications or quick settings by calling:

    • performGlobalAction(GLOBAL_ACTION_NOTIFICATIONS)
    • performGlobalAction(GLOBAL_ACTION_QUICK_SETTINGS)

提交回复
热议问题