几秒钟后,Android Heads-up通知消失 [英] Android Heads-up notification disappears after a few seconds

查看:227
本文介绍了几秒钟后,Android Heads-up通知消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望通知不会在几秒钟后消失.所以我创建了这样的通知:

I would that the notification does not disappear after a few seconds. So i have create the notification like this:

  NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
        builder.setSmallIcon(R.drawable.cast_ic_notification_small_icon)
                .setDefaults(Notification.FLAG_ONGOING_EVENT)
                .setPriority(Notification.PRIORITY_HIGH)
                .setContentTitle(notificationDetails.getSubject())
                .setContentText(notificationDetails.getMessage())
                .setColor(context.getResources().getColor(R.color.colorPrimary))
                .setOngoing(true);

并设置FLAG_ONGOING_EVENT和方法setOngoing(true).

and setting the FLAG_ONGOING_EVENT and the method setOngoing(true).

,但几秒钟后,通知继续消失.我希望该通知仅在用户单击时消失.谢谢.

but after a few seconds the notification continues to disappears. I wish the notification to disappear only when the user clicks on. Thank you.

推荐答案

抬头通知的持续时间无法更改在操作系统级别设置取决于通知系统为其提供多少时间.

Duration of heads-up notification can't be changed It is set at OS level Depends on OS how much time it provides for it.

这篇关于几秒钟后,Android Heads-up通知消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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