I am developing an app for radio streaming using exoplayer library. So, I want to clear(delete) exoplayer notification bar (with play/stop buttons) when I close the app. Now, I close the app but the notification bar still appears and doesn/t close with a swipe left/right.
I try the following source code but it doesn't work.
protected void onDestroy() {
super.onDestroy();
NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(NOTIFICATION_ID);
}
I tried it with the method cancelAll()
etc but it doesn't work too.
It works on onPause()
and onStop()
methods but I want to do this onDestroy()
only.
Thanks in advance.