android - Urban Airship : custom icon for default status bar notification

标签 android urbanairship.com android-notifications android-notification-bar

如果您想对状态栏通知进行任何修改,包括微调图标,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/

相关文章:

android - 在 Android 中读取短信和彩信数据库

iphone - 在应用程序中购买 Urban Airship 帮助

iphone - 将 Urbanairship 集成到我的 iOS 应用程序中所需的最少文件集是什么?

Android 在通知时捕获事件(长按)

android - Dao类的实例未正确初始化

android - 使用 indeterminateDrawable 时,ProgressBar 未显示在设备中心

android - 在 App Billing v3 IllegalArgumentException 中使用 IabHelper

Android UrbanAirship 在起飞时崩溃

Flutter 本地通知 int id 参数

Android 状态栏通知 - 有什么方法可以在状态栏上弹出通知( toast )?