gpt4 book ai didi

android如何创建一个永不关闭的通知

转载 作者:太空宇宙 更新时间:2023-11-03 11:44:16 24 4
gpt4 key购买 nike

我已经使用 NotificationCompat.builder 创建了通知。但我无法通过它设置标志以使其不可取消。

谁能帮我解决我的问题,我将不胜感激。 :)

谢谢你:)

noti_intent = new Intent(this, Main.class);
noti_pend = PendingIntent.getActivity(this, noti_id, noti_intent, 0);
noti_manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
noti = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.status_ico)
.setContentTitle("Next alarm is set to ring on")
.setTicker("Alarm is set to ring")
.setContentText(next_date.getText()+" "+next_time.getText())
.setWhen(System.currentTimeMillis())
.setContentIntent(noti_pend)
.setAutoCancel(false);

最佳答案

setAutoCancel(true) 替换为 setOngoing(true)

关于android如何创建一个永不关闭的通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17256608/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com