Не отображается уведомление на экране блокировки
У меня на Android 9 API28 не отображается уведомление сервиса на экране блокировки, что нужно ещё дописать? Хотя, в чужих приложениях установленных из Маркета уведомления отображаются без добавления каких-либо разрешений. Ну например в приложении Omnia, ZXtune и многих других.
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence charSequence = "My service";
NotificationChannel channel = new NotificationChannel("com.soft.service",charSequence, NotificationManager.IMPORTANCE_DEFAULT);
channel.setDescription("My service");
channel.setLockscreenVisibility(NotificationCompat.VISIBILITY_PUBLIC);
channel.enableVibration(false);
channel.setSound(null, null);
nm.createNotificationChannel(channel);
NotificationCompat.Builder myBuilder = new NotificationCompat.Builder(Mss.this, "com.soft.service")
.setSmallIcon(R.drawable.icon)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setOngoing(true)
.setChannelId("com.soft.service");
startForeground(123, myBuilder.build());