I would that the notification does not disappear after a few seconds. So i have create the notification like this:
NotificationCompat.Builder builder = new
It is actually possible to make a heads-up notification persistent. The trick is to use setFullScreenIntent
. If you don't want your notification to have a full-screen version, you can use a dummy intent that won't actually launch any activity, like this:
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, new Intent(), 0);
notificationBuilder.setFullScreenIntent(pendingIntent, true);
It's a hack, but the behavior makes some sense. If an app is trying to show a full-screen notification, then it must be an important event, like an alarm or a phone call. If the phone decides not to show the full-screen notification, it should probably still show something persistent until the user takes action.
This works on the phones I've tested, but the behavior isn't documented, so there are no guarantees.