Pau*_*sma 4 android urbanairship.com android-notifications android-notification-bar
CustomPushNotificationBuilder如果您想对状态栏通知进行任何修改,Urban Airship建议您创建自定义通知,包括轻松更改图标.
不幸的是,使用RemoteViewfor通知会带来许多与自定义制造商和/或平台特定皮肤相关的不必要的含义,包括文本颜色和对私有资源的引用(例如@*android:drawable/notify_panel_notification_icon_bg_tile在Honeycomb/ICS上).
必须有一种简单的方法来交换图标而不使用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);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2309 次 |
| 最近记录: |