How can I programmatically open/close notifications in Android?

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

    Yes you can add this code to wherever you want it to execute

    Object sbservice = getSystemService( "statusbar" );
    Class statusbarManager = Class.forName( "android.app.StatusBarManager" );
    Method showsb = statusbarManager.getMethod( "expand" );
    showsb.invoke( sbservice );
    

    And add this permission

    
    

提交回复
热议问题