Notification.Builder PendingIntent

本文介绍了如何使用FullScreenIntent在Android应用中设置高优先级通知,使其在全屏状态下立即响应,适用于如来电或闹钟等需要用户即时关注的情况。通过设置参数,开发者可以确保应用的高优先级通知不会被其他通知掩盖,增强用户体验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

设置FullScreenIntent:

 /**
         * An intent to launch instead of posting the notification to the status bar.
         * Only for use with extremely high-priority notifications demanding the user's
         * <strong>immediate</strong> attention, such as an incoming phone call or
         * alarm clock that the user has explicitly set to a particular time.
         * If this facility is used for something else, please give the user an option
         * to turn it off and use a normal notification, as this can be extremely
         * disruptive.
         *
         * @param intent The pending intent to launch.
         * @param highPriority Passing true will cause this notification to be sent
         *          even if other notifications are suppressed.
         */
        public Builder setFullScreenIntent(PendingIntent intent, boolean highPriority) {
            mFullScreenIntent = intent;
            setFlag(FLAG_HIGH_PRIORITY, highPriority);
            return this;
        }

一个全屏状态下替代状态栏上的Notification的intent,仅适用于使用非常高的优先级通知,会引起用户的即时关注,如用户已显式设置为一个特定的时间,一个来电或闹钟。

 builder.setFullScreenIntent(inCallPendingIntent, true);

设置FullScreenIntent后,会立即响应该Intent ,而不会等待用户去手动触发。参看源码 Phone app 下面的NotificationMgr.java 的updateInCallNotification() 方法的设置



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值