【发布时间】:2020-01-20 20:33:08
【问题描述】:
我正在使用 exoplayer 库开发一个用于广播流媒体的应用程序。 所以,我想在关闭应用程序时清除(删除)exoplayer 通知栏(带有播放/停止按钮)。 现在,我关闭了应用程序,但通知栏仍然出现,并且不会通过向左/向右滑动来关闭。
我尝试了以下源代码,但它不起作用。
protected void onDestroy() {
super.onDestroy();
NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(NOTIFICATION_ID);
}
我用cancelAll()等方法试过了,但也没有用。
它适用于 onPause() 和 onStop() 方法,但我只想这样做 onDestroy()。
提前致谢。
【问题讨论】:
标签: android android-studio notifications android-notifications exoplayer