我们调整了我们在奥利奥系统上的持续通知,效果非常好。但是现在,在Pie系统上(奥利奥设备上没有发生),我们遇到了标题错误。在Pie系统中,前台服务是否有所改变,我错过了什么吗?
下面是前台服务的onCreate代码 ->
下面是前台服务的onCreate代码 ->
override fun onCreate() {
super.onCreate()
val notification: Notification = NotificationCompat.Builder(this, packageName)
.setSmallIcon(R.drawable.status_notification_icon)
.setContentTitle(getString(R.string.ongoing_notify_temp_title))
.setContentText(getString(R.string.ongoing_notify_temp_message))
.setGroup(AppConstants.NOTIFICATION_GROUP_ONGOING)
.setColor(ContextCompat.getColor(this, R.color.custom_blue))
.build()
startForeground(ONGOING_NOTIFY_ID, notification)
appSettings = AppSettings(this)
weatherLookUpHelper = WeatherLookUpHelper()
MyRoomDatabase.getInstance().invalidationTracker.addObserver(onChange)
retrieveCurrentLocation()
createAlarmManager()
}
正如您所看到的,我们只是创建通知,然后调用startForeground。有什么想法,为什么这段代码会生成标题错误?
旁注:Fabric Crashlytics 仅显示在运行 Pie 的 Pixel 设备(像素,像素 xl,像素2,像素2 xl)上发生此崩溃。
编辑: 我们在清单中拥有前台权限。
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
Manifest.permission.FOREGROUND_SERVICE
权限吗? - May Rest in Peace