Android通知FLAG_AUTO_CANCEL不工作 [英] Android Notification FLAG_AUTO_CANCEL not working

查看:833
本文介绍了Android通知FLAG_AUTO_CANCEL不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我想用低于code取消点击通知,但由于某种原因它总是显示在通知区域正在进行部分通知,不能太清楚..

I want cancel notification on click using code below but some reason it always shows notification in Ongoing section in Notifications area and could not clear too ..

  NOTIFICATION_ID = NOTIFICATION_ID + 1;
  Intent intent1 = new Intent(this, MyClass.class);
  PendingIntent pii = PendingIntent.getActivity(this, 1, intent1, 0);
  Notification notification1 = new Notification(R.drawable.icon, "test",
    System.currentTimeMillis());

  notification1.setLatestEventInfo(this,
    "test", "test", pii);

  notification1.flags |= Notification.FLAG_AUTO_CANCEL;
  startForeground(NOTIFICATION_ID, notification1);

感谢

推荐答案

FLAG_AUTO_CLEAR 工作startForeground()

这篇关于Android通知FLAG_AUTO_CANCEL不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆