【发布时间】:2020-03-05 16:46:01
【问题描述】:
我正在尝试使用自定义 remoteView 创建媒体播放器控件通知。我遇到的问题是,每次我在远程视图中更改某些内容时,我都需要取消通知并从头开始重建它。这种方法对性能非常不利,因为它明显滞后。 (即将暂停图标更改为仅播放图标,我需要重建整个通知并重新加载专辑图像)
我尝试更改 remoteView,然后使用 NotificationBuilder.setCustomContentView 重新设置它,但它不起作用,这里是更改播放和暂停图标的代码:
public void PlayPause(){
this.play=!this.play;
if (this.play) {
Bitmap toggleBmp = BitmapFactory.decodeResource(parent.getResources(), R.drawable.baseline_pause_black_48);
remoteView.setImageViewBitmap(R.id.toggle, changeBitmapColor(toggleBmp,Color.parseColor(iconColor)));
} else {
Bitmap toggleBmp = BitmapFactory.decodeResource(parent.getResources(), R.drawable.baseline_play_arrow_black_48);
remoteView.setImageViewBitmap(R.id.toggle, changeBitmapColor(toggleBmp,Color.parseColor(iconColor)));
}
nBuilder.setCustomContentView(remoteView);
}
上面的代码不起作用,图标也没有改变。
【问题讨论】:
标签: java android notifications