Sur*_*rai 6 notifications android
我在服务开始时创建了通知,但我不知道如何在服务停止或销毁时关闭该通知.有任何想法.
以下代码在服务启动时启动通知.
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);
Run Code Online (Sandbox Code Playgroud)
app*_*ter 24
使用通知管理员#cancel和您的通知ID
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.cancel(KEEPUS_NOTIFICATION_ID);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
16539 次 |
最近记录: |