城市飞艇:默认状态栏通知的自定义图标 [英] Urban Airship: custom icon for default status bar notification

查看:87
本文介绍了城市飞艇:默认状态栏通知的自定义图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您想对状态栏通知进行任何修改(包括微调图标),城市飞艇建议使用CustomPushNotificationBuilder创建自定义通知.

Urban Airship recommends creating a custom notification with CustomPushNotificationBuilder if you want to make any modifications to the status bar notification, including trivially changing the icon.

不幸的是,使用RemoteView进行通知会带来许多与自定义制造商和/或特定于平台的外观有关的不必要的暗示,

Unfortunately, using a RemoteView for notifications carries many unwanted implications with it related to custom manufacturer and/or platform-specific skins, including text colors and references to private resources (for instance @*android:drawable/notify_panel_notification_icon_bg_tile on Honeycomb/ICS).

必须有一种简单的方法来交换图标,而无需使用RemoteView.怎么样?

There must be a simple way to swap the icon without using RemoteView. How?

推荐答案

我发现通过覆盖BasicPushNotificationBuilder,我可以非常简单地设置图标:

I found that by overriding BasicPushNotificationBuilder, I can set the icon quite trivially:

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);

这篇关于城市飞艇:默认状态栏通知的自定义图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆