Rad*_*esh 1 notifications android android-8.0-oreo
setDefaults 在Android O及更高版本(SDK> = 26)中,Notification.Builder中的版本已弃用
也 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());`
Run Code Online (Sandbox Code Playgroud)
我应该更换什么?我找不到任何有用的例子
| 归档时间: |
|
| 查看次数: |
2913 次 |
| 最近记录: |