android - 在 Notification.Builder 中不推荐使用 setDefaults
问题描述
setDefaults
在 Notification.Builder 中已弃用 android O 及更高版本 (SDK >= 26)
还setSound
这是我的代码
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
b.setAutoCancel(true)
.setSmallIcon(R.drawable.ic_luncher_new)
.setContentTitle(Title)
.setTicker(Title)
.setContentText(Msg)
.setChannelId("cid")
.setDefaults(Notification.DEFAULT_ALL)
.setStyle(new Notification.BigTextStyle().bigText(Msg))
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setContentIntent(contentIntent);
}
NotificationManager notificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notificationManager.createNotificationChannel(mChannel);
}
notificationManager.notify(id, b.build());`
我应该更换什么?我没有找到任何有用的例子
解决方案
推荐阅读
- google-sheets - 尝试使用宏制作脚本 - 代码太长
- apache - 当在 Apache 上指定 X-Frame-Options 时,如何修复 Safari 忽略 Content-Security-Policy?
- latex - Latex pgfplots:组图中的范围插图
- c# - 即使是好的查询也无法在 Oracle 中捕获重复的行
- javascript - 如何在上下文菜单中触发全局功能
- java - 在列表中选择具有条件值的组的最佳设计模式可能会有所不同?
- reactjs - 定义对象时的打字稿对象属性
- delphi - 如何关闭我称之为模态表单的模态表单
- sql - SQL:一旦达到唯一分组,分组依据中的列是否重要?
- python - mac os + apache 2.4.33 + python 3.7.2 + django 2.1.5 + mod_wsgi 4.6.5(无法访问站点)