I am building Notification with remote views. I have given NotificationCompat.VISIBILITY_PUBLIC. but Notification is not showing on lock screen in Oreo.
My compileSdkVersion and targetSdkVersion is 27
remoteViews = new RemoteViews(getPackageName(), R.layout.player_noti_layout);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel("default",
getString(R.string.player_channel),
NotificationManager.IMPORTANCE_LOW);
channel.setDescription("Notification, Play/pause & Next/Prev");
channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
notificationmanager.createNotificationChannel(channel);
}
builder = new NotificationCompat.Builder(this, "default");
Notification foregroundNote;
// Set Icon
foregroundNote = builder.setSmallIcon(R.drawable.ic_radio)
.setTicker(getResources().getString(R.string.app_name))
.setAutoCancel(false).setOngoing(true)
.setContent(remoteViews)
.setContentTitle("app name").setContentText("").setWhen(0).setPriority(NotificationCompat.PRIORITY_MAX)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.build();
Help appreciated!!! Thanks
try this:
Notification.Builder.setVisibility(Notification.VISIBILITY_PUBLIC);