gpt4 book ai didi

java - 如何阻止通知面板隐藏?

转载 作者:行者123 更新时间:2023-11-29 04:49:56 25 4
gpt4 key购买 nike

我想用按钮发出通知。但是在点击按钮后-通知面板被隐藏了。我该怎么办?我正在使用此代码创建我的通知:

public class MyNotification extends Notification {
private Context ctx;
private NotificationManager mNotificationManager;



public MyNotification (Context ctx, int layaut_id) {
super();
this.ctx = ctx;
String ns = Context.NOTIFICATION_SERVICE;

mNotificationManager = (NotificationManager) ctx.getSystemService(ns);
CharSequence tickerText = "Shortcuts";
long when = System.currentTimeMillis();

Notification.Builder builder = new Notification.Builder(ctx);
Notification notification = builder.getNotification();
notification.when = when;
notification.tickerText = tickerText;
notification.icon = R.drawable.ic_launcher;

RemoteViews contentView = new RemoteViews(ctx.getPackageName(), layaut_id);


//set button listners
setListeners(contentView);

notification.contentView = contentView;
notification.flags |= Notification.FLAG_NO_CLEAR;
CharSequence contentTitle = "From Shortcuts";
mNotificationManager.notify(1387, notification);

}

最佳答案

可能您的通知在您单击时自动取消。要禁用此添加:

builder.setAutoCancel(false);

关于java - 如何阻止通知面板隐藏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35841562/

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