做网站的职责电子商务营销与传统营销的区别
news/
2025/10/6 14:39:35/
文章来源:
做网站的职责,电子商务营销与传统营销的区别,wordpress手机版中文,做音乐相册的网站Android#xff1a;从通知中删除通知b我已经创建了一个应用程序#xff0c;并且我设法在android通知栏中添加通知。 现在我需要示例如何从事件通知栏中删除该通知#xff1f;11个解决方案197 votes你可以尝试这个快速代码public static void cancelNotification(Context ctx…Android从通知中删除通知b我已经创建了一个应用程序并且我设法在android通知栏中添加通知。 现在我需要示例如何从事件通知栏中删除该通知11个解决方案197 votes你可以尝试这个快速代码public static void cancelNotification(Context ctx, int notifyId) {String ns Context.NOTIFICATION_SERVICE;NotificationManager nMgr (NotificationManager) ctx.getSystemService(ns);nMgr.cancel(notifyId);}Ankit Patial answered 2019-05-23T02:26:35Z155 votes这很简单。 您必须在NotificationManager上调用cancel或cancelAll。 cancel方法的参数是应该取消的通知的ID。请参阅API[http://developer.android.com/reference/android/app/NotificationManager.html#cancel(int)]RoflcoptrException answered 2019-05-23T02:26:10Z58 votes您也可以在通知管理器上调用cancelAll这样您甚至不必担心通知ID。NotificationManager notifManager (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);notifManager.cancelAll();编辑我被downvoted所以也许我应该指定这只会从您的应用程序中删除通知。Stephane Mathis answered 2019-05-23T02:27:06Z10 votes只需像下面的代码一样设置setAutoCancel(True)Intent resultIntent new Intent(GameLevelsActivity.this, NotificationReceiverActivityAdv.class);PendingIntent resultPendingIntent PendingIntent.getActivity(GameLevelsActivity.this,0,resultIntent,PendingIntent.FLAG_UPDATE_CURRENT);NotificationCompat.Builder mBuilder new NotificationCompat.Builder(getApplicationContext()).setSmallIcon(R.drawable.icon).setContentTitle(adv_title).setContentText(adv_desc).setContentIntent(resultPendingIntent)//HERE IS WHAT YOY NEED:.setAutoCancel(true);NotificationManager manager (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);manager.notify(547, mBuilder.build());farhad.kargaran answered 2019-05-23T02:27:30Z6 votes如果要从使用前台启动的服务生成通知startForeground(NOTIFICATION_ID, notificationBuilder.build());然后发行notificationManager.cancel(NOTIFICATION_ID);取消通知amp; 通知仍会显示在状态栏中。 在这种特殊情况下您将通过两种方式解决这些问题1 GT; 在服务中使用stopForeground(false)stopForeground( false );notificationManager.cancel(NOTIFICATION_ID);2 - ; 使用调用活动销毁该服务类Intent i new Intent(context, Service.class);i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);if(ServiceCallingActivity.activity ! null) {ServiceCallingActivity.activity.finish();}context.stopService(i);第二种方式更喜欢音乐播放器通知更多因为不仅通知删除而且还删除播放器... !!Dhruv Raval answered 2019-05-23T02:28:30Z5 votes这将有助于NotificationManager mNotificationManager (NotificationManager)getSystemService(NOTIFICATION_SERVICE);mNotificationManager.cannelAll();如果您通过调用创建通知startForeground();在Service.you可能需要打电话stopForeground(false);首先然后取消通知。pilotmario answered 2019-05-23T02:29:15Z1 votes使用NotificationManager取消通知。 您只需提供通知ID即可mNotificationManager.cancel(YOUR_NOTIFICATION_ID);还请查看此链接见Developer LinkMuhammad Usman Ghani answered 2019-05-23T02:29:54Z1 votes在Android APIgt; 23上您可以执行以下操作来删除一组通知。for (StatusBarNotification statusBarNotification : mNotificationManager.getActiveNotifications()) {if (KEY_MESSAGE_GROUP.equals(statusBarNotification.getGroupKey())) {mNotificationManager.cancel(statusBarNotification.getId());}}Szabolcs Becze answered 2019-05-23T02:30:18Z1 votesNotificationManager.cancel(id)是正确的答案。 然而您可以通过删除整个通知渠道来删除Android Oreo及更高版本的通知。 这应删除已删除频道中的所有邮件。以下是Android文档中的示例NotificationManager mNotificationManager (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);// The id of the channel.String id my_channel_01;mNotificationManager.deleteNotificationChannel(id);gil.fernandes answered 2019-05-23T02:30:49Z1 votes请试试这个public void removeNotification(Context context, int notificationId) {NotificationManager nMgr (NotificationManager) context.getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);nMgr.cancel(notificationId);}Akansha patel answered 2019-05-23T02:31:09Z0 votes只需拨打IDpublic void delNoti(int id) {((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).cancel(id);}phnghue answered 2019-05-23T02:31:35Z
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/929416.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!