我目前正在尝试在 Nexus S (API 29) 上获取标题通知,但没有成功。我见过一些具有各种解决方案的线程,但没有一个有效。代码如下:
Context applicationContext = getApplicationContext();
NotificationCompat.Builder builder = new NotificationCompat.Builder(applicationContext, CHANNEL_ID)
.setDefaults(NotificationCompat.DEFAULT_ALL)
.setDefaults(NotificationCompat.DEFAULT_SOUND)
.setSmallIcon(R.drawable.ic_account_circle)
.setContentTitle(notificationTitle)
.setContentText(notificationTextBody)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setLights(Color.RED, 3000, 3000);
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(applicationContext);
int notificationId = new Random().nextInt();
//launches the notification on the device
notificationManager.notify(notificationId, builder.build());
我试过设置声音,振动,将优先级设置为高或最大。我什至使用了这种方法setFullScreenIntent
,单独地一次全部使用,但没有完成我所寻求的。