How to properly clear all notification once clicked?

前端 未结 2 1332
春和景丽
春和景丽 2021-01-07 17:22

I send a few notification on the notification bar, i wanted to clear all of it when one of the notification is clicked. For now I clear one by one by using Flag. I know

2条回答
  •  执笔经年
    2021-01-07 17:38

    My solution is to call it at onResume().

    @Override
    protected void onResume() {
    super.onResume();
    
    // Clear all notification
    NotificationManager nMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    nMgr.cancelAll();
    } 
    

提交回复
热议问题