简体   繁体   English

在没有弹出的情况下创建通知

[英]Create notification without it popping up

I'm trying to add an android notification to the "tray" in android 3, but I don't want it to "pop up" every time I call notify(). 我正在尝试向android 3中的“托盘”添加一个android通知,但我不希望每次调用notify()时它都会“弹出”。

I managed to kind of do this by setting the FLAG_ONLY_ALERT_ONCE flag on the notification, but it will still alert when I set it for the first time. 我设法通过在通知上设置FLAG_ONLY_ALERT_ONCE标志来做到这一点,但是当我第一次设置它时它仍然会发出警报。

It seems like this is possible, but I'm not sure how to do this (an example is the Prime ROM for the Asus transformer. When you plug in the dock, a new ongoing notification will be added to the notification area, but there is no alert, or "popup" there.. It just adds another icon to the list quietly. How can I do the same? 看起来这是可能的,但我不知道如何做到这一点(一个例子是华硕变压器的Prime ROM。当你插入基座时,一个新的持续通知将被添加到通知区域,但那里没有警报,或“弹出”那里..它只是静静地在列表中添加另一个图标。我怎么能这样做?

Just set the tickerText to null. 只需将tickerText设置为null即可。 You can do this when creating your notification with: 您可以在创建通知时执行以下操作:

Notification notification = new Notification( R.drawable.icon, null, System.currentTimeMillis());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android FCM 通知未弹出 - Android FCM Notification Not Popping Up PHP Firebase通知显示在托盘中,但没有弹出 - PHP Firebase notification shows in tray but not popping up Android 通知显示但未在屏幕上弹出 - Android Notification Showing but not popping up on the screen 正在创建通知,但未在Android中弹出(在Pie中) - Notification is being created but not popping up in android (in Pie) 设置通知时弹出通知:android studio alarm manager - Notification popping up just as I set notification : android studio alarm manager 如何在不弹出任何对话框的情况下注销Facebook? - How to log out of Facebook without any dialog box popping up? Flutter 授权后仍然弹出通知访问界面 - Notification access screen keeps popping up even after granting the permission in Flutter TextView不断弹出 - TextView keeps popping up 部署失败:INSTALL_FAILED_USER_RESTRICTED:安装被用户取消,没有弹出允许窗口 - Deployment failed: INSTALL_FAILED_USER_RESTRICTED: Install canceled by User without allow-window popping up 在 android 中,如何在不弹出“选择浏览器”列表的情况下强制使用特定浏览器打开 URI? - In android, How can I force open a URI using a specific browser, without popping up the 'choose browser' list?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM