我已经创建了一个在服务启动时触发的通知,但我不知道如何在服务停止或销毁时关闭该通知。你有什么想法吗?
以下是在服务启动时触发通知的代码。
以下是在服务启动时触发通知的代码。
String ns = Context.NOTIFICATION_SERVICE;
final int KEEPUS_NOTIFICATION_ID = 1;
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns);
Notification notification = new Notification(R.drawable.notification_icon1, ticker_text, System.currentTimeMillis());
Intent notificationIntent = new Intent(context, KeepusActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, ticker_content_title, ticker_content_text,contentIntent);
mNotificationManager.notify(KEEPUS_NOTIFICATION_ID, notification);