开发者

Close android Notification

i have create notification when service start but i have not idea how to close that notification when service stop or on destroy. have any idea.

following code that start notification when service start.

String ns = Context.NOTIFICATION_SERVICE;
    final int KEEPUS_NOTIFICATION_ID = 1;
    NotificationManager mNotificationMa开发者_StackOverflow社区nager = (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);


use notification manager #cancel with your notification id

NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.cancel(KEEPUS_NOTIFICATION_ID);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜