gpt4 book ai didi

android - 在没有通知的情况下显示代码文本

转载 作者:搜寻专家 更新时间:2023-11-01 08:50:53 25 4
gpt4 key购买 nike

我的项目有一个要求。我们想在状态栏中显示时间和网络信号图标的文本。但我们不想收到通知。文本只是显示,像往常一样滚动然后完全消失。面板中不应有通知。知道如何实现这一目标吗?我知道没有直接的方法可以做到这一点。任何人都可以提供任何破解吗?

更新:

我能够生成通知并在一段时间后取消它。为此,我创建了一个处理程序并在一段时间后将其取消。但是现在的问题是根据文本大小来计算时间。我只想在通知完全推出时取消通知。

final NotificationManager mNotificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
context)
.setSmallIcon(R.drawable.icon)
.setTicker("abcd efgh ijkl mnop qrst uvwx yz abcd efgh ijkl mnop qrst uvwx yz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz")

.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
.setOnlyAlertOnce(true);




mNotificationManager.notify(SharedPreferenceUtil.getInstance()
.getNotificationId(context), mBuilder.build());

Handler handler = new Handler();

handler.postDelayed(new Runnable() {

@Override
public void run() {
Utility.Log("Notification Removed", Log.VERBOSE);
mNotificationManager.cancel(id);
}
}, 10000);

Utility.Log("Notification Posted", Log.VERBOSE);

最佳答案

是的,你可以做到

您可以这样设置通知:

notificationManager.notify(0, notification);

然后你可以像这样从通知列表中删除

NotificationManager notificationmanager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationmanager.cancel(0);

关于android - 在没有通知的情况下显示代码文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23604516/

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