我正在使用远程视图构建通知。我已经设置了NotificationCompat.VISIBILITY_PUBLIC,但是在Oreo锁屏界面上没有显示通知。
我的compileSdkVersion和targetSdkVersion都是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
IMPORTANCE_LOW
更改为IMPORTANCE_HIGH
。 - Ümañg ßürmån