赞
踩
u=1678011113,2635959946&fm=26&gp=0.jpg
对于大于等于API 26 [Build.VERSION.SDK_INT >= Build.VERSION_CODES.O],您需要在通知通道上设置声音
fun createNotifyChannel(context: Context): String? {
val sound = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + context.packageName + "/raw/" + R.raw.sound)
// NotificationChannels are required for Notifications on O (API 26) and above.
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val audioAttributes = AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_NOTIFICATION)
.build()
// Initializes NotificationChannel.
val notificationChannel = NotificationChannel
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。