NotificationUtils

通知栏工具类

Author

Jenly

Follow me

Functions

Link copied to clipboard
fun cancelNotification(context: Context, notificationId: Int)

取消通知

Link copied to clipboard
fun createNotificationChannel(context: Context, channelId: String, channelName: String, isVibrate: Boolean, isSound: Boolean)

创建一个通知通道(兼容O以上版本)

Link copied to clipboard
Link copied to clipboard
fun showErrorNotification(context: Context, notificationId: Int, channelId: String, @DrawableRes smallIcon: Int, title: CharSequence, content: CharSequence, allowRetry: Boolean)

显示下载出错通知

Link copied to clipboard
fun showNotification(context: Context, notificationId: Int, channelId: String, @DrawableRes smallIcon: Int, title: CharSequence, content: CharSequence, isAutoCancel: Boolean)

显示通知信息(非第一次)

Link copied to clipboard
fun showProgressNotification(context: Context, notificationId: Int, channelId: String, @DrawableRes smallIcon: Int, title: CharSequence, content: CharSequence, progress: Long, total: Long, supportCancelDownload: Boolean)

显示下载中的通知(更新进度)

Link copied to clipboard
fun showStartNotification(context: Context, notificationId: Int, channelId: String, channelName: String, @DrawableRes smallIcon: Int, title: CharSequence, content: CharSequence, isVibrate: Boolean, isSound: Boolean, supportCancelDownload: Boolean)

显示开始下载时的通知

Link copied to clipboard
fun showSuccessNotification(context: Context, notificationId: Int, channelId: String, @DrawableRes smallIcon: Int, title: CharSequence, content: CharSequence, file: File, authority: String)

显示下载成功时的通知(点击安装)