根据文档,我已经在应用程序中进行了更改,以便在后台使用context.startForegroundService(Intent)
然后startForeground
像以前一样调用服务来启动服务。
NotificationCompat.Builder notification = new
NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.mipmap.icon)
.setContentText("Content")
.setOngoing(true)
.setContentInfo("Info")
.setContentTitle("Title");
startForeground(1, notification.build());
这会在 Android N 设备上正确显示通知,但在 Android O 设备上它不会显示通知,它只显示新的“正在后台运行...点击以获取有关电池和数据使用情况的更多详细信息”
是否缺少让通知在 Android O 上正确显示的内容?