Jac*_*hen 7 notifications android
我在"onCreate"活动方法中创建了一个通知.
一切运行顺利,只需按"全部删除"按钮即可关闭.
如何制作此通知perma?因为它应该只是一个信息而不是通知..
这是我目前的代码:
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);
}
Run Code Online (Sandbox Code Playgroud)
小智 20
在通知构建器上使用.setOngoing(true).这将阻止用户删除您的通知.
有关详细信息,请参阅Notification Builder文档:http: //developer.android.com/reference/android/app/Notification.Builder.html#setOngoing%28boolean%29