Is there any ways for turning on the banners setting (display on top of the status bar) in application notification programmatically?
<pre><code>
// send notification to NotificationManager
Notification.Builder notificationBuilder =new Notification.Builder(context);
notificationBuilder.setSmallIcon(R.drawable.icon_32x32)
.setLargeIcon(bitmap)
.setContentTitle("title")
.setContentText("content")
.setContentIntent(contentIntent)
.setAutoCancel(true)
.setDefaults(Notification.DEFAULT_ALL)
.setPriority(Notification.PRIORITY_HIGH)
.setCategory(Notification.CATEGORY_MESSAGE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
notificationBuilder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
}
NotificationManager notificationManager =
(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(id, notificationBuilder.build());
</code></pre>
Same problem. I solved this issue simply adding in the AndroidManifest.xml the ACCESS_NOTIFICATION_POLICY permission:
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
Nothing more is required (at least for me).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With