相关疑难解决方法(0)

Android通知FLAG_AUTO_CANCEL无效

大家好

我希望点击使用下面的代码取消通知,但有些原因它总是在通知区域的正在进行的部分显示通知,但也无法清除..

  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);
Run Code Online (Sandbox Code Playgroud)

谢谢

service notifications android

2
推荐指数
1
解决办法
5977
查看次数

标签 统计

android ×1

notifications ×1

service ×1