我在我的"onCreate“活动方法中创建了一个通知。
一切都运行得很顺利,只是你可以通过按“全部删除”按钮来关闭它。
如何使此通知成为永久通知?因为它应该只是一个信息而不是通知..
这是我当前的代码:
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);
}发布于 2014-03-21 19:12:15
在通知构建器上使用.setOngoing(true)。这将阻止用户删除您的通知。
有关详细信息,请参阅通知构建器文档:http://developer.android.com/reference/android/app/Notification.Builder.html#setOngoing%28boolean%29
发布于 2014-03-21 19:13:41
好的,在你的代码中添加如下代码:
n.flags |= Notification.FLAG_NO_CLEAR;https://stackoverflow.com/questions/22555943
复制相似问题