gpt4 book ai didi

Android - 如何创建永久通知

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:08:13 25 4
gpt4 key购买 nike

我已经在我的“onCreate” Activity 方法中创建了一个通知。

一切运行顺利,只是您可以通过按“全部删除”按钮将其关闭。

如何使此通知永久化?因为它应该只是更多的信息而不是通知..

这是我当前的代码:

    private void showNotification() {
// TODO Auto-generated method stub
nMN = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification n = new Notification.Builder(this)
.setContentTitle("Whip And Weep")
.setContentText("Whip is On!")
.setSmallIcon(R.drawable.ic_launcher)
.build();
nMN.notify(NOTIFICATION_ID, n);
}

最佳答案

在您的通知构建器上使用 .setOngoing(true)。这将阻止用户删除您的通知。

有关详细信息,请参阅通知生成器文档: http://developer.android.com/reference/android/app/Notification.Builder.html#setOngoing%28boolean%29

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

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