如果您想对状态栏通知进行任何修改,包括微调图标,Urban Airship 建议使用 CustomPushNotificationBuilder
创建自定义通知。
不幸的是,使用 RemoteView
进行通知会带来许多与自定义制造商和/或特定于平台的皮肤相关的不良影响,including text colors以及对私有(private)资源的引用(例如 Honeycomb/ICS 上的 @*android:drawable/notify_panel_notification_icon_bg_tile
)。
必须有一种无需使用 RemoteView
即可交换图标的简单方法。怎么办?
最佳答案
我发现通过覆盖 BasicPushNotificationBuilder
,我可以非常简单地设置图标:
BasicPushNotificationBuilder nb = new BasicPushNotificationBuilder() {
@Override
public Notification buildNotification(String alert,
Map<String, String> extras) {
Notification notification = super.buildNotification(alert,
extras);
// The icon displayed in the status bar
notification.icon = R.drawable.notification;
// The icon displayed within the notification content
notification.contentView.setImageViewResource(
android.R.id.icon, R.drawable.notification);
return notification;
}
};
// Set the custom notification builder
PushManager.shared().setNotificationBuilder(nb);
关于android - Urban Airship : custom icon for default status bar notification,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10666022/