代码:
fun updateProgress(process: Int) {
val notify = notifyContents[notifyId]?:return
if (Build.VERSION.SDK_INT >= 24){
val build = Notification.Builder.recoverBuilder(context,notify)
build.setProgress(100,process,false)
getManager().notify(notifyId,notify)
}else{
notify.contentView.setProgressBar(android.R.id.progress,100,process,false)
getManager().notify(notifyId,notify)
}
}
说明:
根据源码注释,找到更新此notification的进度条方法:

contentView在N 以上都为null,我们可以根据提示的方法找到对应的build,然后根据build获取build来更新UI组件,达到我们更新notification的进度条的目的。
网友评论