我有一个简单的通知,适用于较旧的Android。但是,使用android oreo时,此通知不会在我的手机上弹出。我读到我需要为频道分配通知,这是我做的。但仍然不会弹出。
谢谢
我的代码-
String CHANNEL_ID = "my_channel_01";
String name = "notification";
int importance = NotificationManager.IMPORTANCE_HIGH;
NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, name, importance);
NotificationManager mManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification.Builder(this,CHANNEL_ID)
.setContentTitle("New Message")
.setContentText("You've received new messages.")
.setSmallIcon(R.drawable.common_google_signin_btn_icon_dark)
.setChannelId(CHANNEL_ID)
.build();
答案 0 :(得分:0)
我认为您缺少mManager.createNotificationChannel(mChannel);