How can I programmatically open/close notifications in Android?

前端 未结 7 2490
无人及你
无人及你 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:48

    Here's the showNotifications method from Android's Launcher:

    private void showNotifications() {
        final StatusBarManager statusBar = (StatusBarManager) getSystemService(STATUS_BAR_SERVICE);
        if (statusBar != null) {
            statusBar.expand();
        }
    }
    

    (which, as Robby indicated, is the "statusbar" system service).

提交回复
热议问题