Reputation: 376
I would like to enable all of the notification options, but I can't do it(see sreenshot). I installed telegram and all of the options for it are enabled by default. Why and how?
Currently I have this code:
NotificationManager notifManager=(NotificationManager)getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel mChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, "My Notifications", NotificationManager.IMPORTANCE_HIGH);
// Configure the notification channel.
mChannel.setDescription("Common notifications");
mChannel.enableLights(true);
mChannel.setLightColor(Color.RED);
mChannel.setVibrationPattern(new long[]{0, 1000, 500, 1000});
mChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
mChannel.enableVibration(true);
notifManager.createNotificationChannel(mChannel);
}
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(getApplicationContext(), NOTIFICATION_CHANNEL_ID)
.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setWhen(System.currentTimeMillis())
.setSmallIcon(icon)
.setColor(color)
.setTicker("")
.setContentTitle("Title")
.setContentText("ContextText")
.setContentInfo("Info")
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setAutoCancel(true);
NotificationManager mNotificationManager =
(NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(SOMEID, mBuilder.build());
Upvotes: 1
Views: 3093
Reputation: 21
I add this permission to Android Manifest file. It worked for me.
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
Upvotes: 1