Q:

Notification.Builder and FLAG_INSISTENT

I like the ease of use of Notification.Builder but it seems not support the insistent mode of notifications.
Is there a way to set the flag FLAG_INSISTENT from the Notification.Builder?

A:

Not directly. There is a private setFlag() method on Notification.Builder -- I do not know why they did not expose it.
However, you can configure the rest of the Notification via a Builder, then adjust the flags on the completed Notification object.
Or, grab the code for Notification.Builder and modify it to create your own that exposes setFlag(), or adds setInsistent(), etc.

A:

Maybe my answer can be useful to someone else
You can use:
NotificationCompat.Builder builder = new NotificationCompat.Builder(getContext());

builder.setContentTitle("Title")
       .setContentText("Hello world")
       .setSmallIcon(R.mipmap.ic_launcher);

Notification notification = builder.build();
notification.flags = Notification.FLAG_INSISTENT;
final NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(ID, notification)

