Permanent notification error

时间:2018-05-17 14:58:17

标签: android

I have big problem with permanent notification i cant add codes like FLAG_NO_CLEAR etc. What can i do? Here Is my code:

Notification.Builder mBuilder = new Notification.Builder(NoteActivity.this);
mBuilder.setSmallIcon(R.drawable.ic_assignment_late_black);
mBuilder.setContentTitle("Alert!");
mBuilder.setContentText(notess);
mBuilder.setDefaults( Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE);

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

Intent notificationIntent = new Intent(getApplicationContext(),MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, Intent.FLAG_ACTIVITY_NEW_TASK);

mBuilder.setContentIntent(pendingIntent).setAutoCancel(false);
notificationManager.notify(0, mBuilder.build());

1 个答案:

答案 0 :(得分:0)

使用Notification.Builder设置正在进行的通知

mBuilder.setOngoing(true);