use*_*549 5 android android-notifications
我正在使用startForeground(id,notification)从intent服务创建通知.
Random r=new Random();
int id=r.nextInt(9999);
Builder notice2=new Notification.Builder(getApplicationContext())
.setContentTitle(call.getName())
.setAutoCancel(true)
.setContentIntent(intent)
.setContentText("content")
.setSmallIcon(com.project.calltracker.R.drawable.ic_alert)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), com.project.calltracker.R.drawable.ic_logo));
startForeground(id, notice2.getNotification());
Run Code Online (Sandbox Code Playgroud)
这里我设置了AutoCancel(true)
但是当我点击通知时它不会消失?
我真的很困惑.我已经尝试过几个小时但仍然没有运气!
请帮忙!
谢谢!
use*_*549 12
我从另一篇文章的答案中找到了答案.基本上只有一个前台服务.使用startForeground()生成通知意味着只要此服务正在运行,就无法删除通知.
而是使用NotificationManager.notify()只生成通知.为此通知设置AutoCancel(true)会使其在滑动/单击时消失.
谢谢!
| 归档时间: |
|
| 查看次数: |
6331 次 |
| 最近记录: |