当前位置: 首页>>代码示例>>Java>>正文


Java NotificationCompat.DEFAULT_LIGHTS属性代码示例

本文整理汇总了Java中android.support.v4.app.NotificationCompat.DEFAULT_LIGHTS属性的典型用法代码示例。如果您正苦于以下问题:Java NotificationCompat.DEFAULT_LIGHTS属性的具体用法?Java NotificationCompat.DEFAULT_LIGHTS怎么用?Java NotificationCompat.DEFAULT_LIGHTS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.support.v4.app.NotificationCompat的用法示例。


在下文中一共展示了NotificationCompat.DEFAULT_LIGHTS属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showNotification

void showNotification(Context context, NotificationRule rule) {
    NotificationMessage lastMessage;
    synchronized (this) {
        if (mMessages.size() == 0)
            return;
        lastMessage = mMessages.get(mMessages.size() - 1);
    }

    String title = getChannel() + " (" + mConnection.getName() + ")"; // TODO: Move to strings.xml
    RemoteViews notificationsView = createCollapsedMessagesView(context, title, lastMessage);
    RemoteViews notificationsViewBig = createMessagesView(context, title);
    NotificationCompat.Builder notification = new NotificationCompat.Builder(context);
    PendingIntent intent = PendingIntent.getActivity(context, mNotificationId,
            MainActivity.getLaunchIntent(context, mConnection, mChannel),
            PendingIntent.FLAG_CANCEL_CURRENT);
    PendingIntent dismissIntent = PendingIntent.getBroadcast(context,
            CHAT_DISMISS_INTENT_ID_START + mNotificationId,
            NotificationDismissReceiver.getIntent(context, mConnection, mChannel),
            PendingIntent.FLAG_CANCEL_CURRENT);
    notification
            .setContentTitle(title)
            .setContentText(lastMessage.getNotificationText(context))
            .setContentIntent(intent)
            .setAutoCancel(true)
            .setPriority(NotificationCompat.PRIORITY_HIGH)
            .setSmallIcon(R.drawable.ic_notification_message)
            .setCustomContentView(notificationsView)
            .setCustomBigContentView(notificationsViewBig)
            .setGroup(NotificationManager.NOTIFICATION_GROUP_CHAT)
            .setStyle(new NotificationCompat.DecoratedCustomViewStyle())
            .setColor(context.getResources().getColor(R.color.colorNotificationMention))
            .setDeleteIntent(dismissIntent);
    int defaults = 0;
    if (rule.settings.soundEnabled) {
        if (rule.settings.soundUri != null)
            notification.setSound(Uri.parse(rule.settings.soundUri));
        else
            defaults |= NotificationCompat.DEFAULT_SOUND;
    }
    if (rule.settings.vibrationEnabled) {
        if (rule.settings.vibrationDuration != 0)
            notification.setVibrate(new long[]{rule.settings.vibrationDuration});
        else
            defaults |= NotificationCompat.DEFAULT_VIBRATE;
    }
    if (rule.settings.lightEnabled) {
        if (rule.settings.light != 0)
            notification.setLights(rule.settings.light, 500, 2000); // TODO: Make those on/off values customizable?
        else
            defaults |= NotificationCompat.DEFAULT_LIGHTS;
    }
    if (!rule.settings.soundEnabled && !rule.settings.vibrationEnabled) {
        notification.setVibrate(new long[]{0}); // a hack to get a headsup to show
    }
    notification.setDefaults(defaults);
    NotificationManagerCompat.from(context).notify(mNotificationId, notification.build());
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:57,代码来源:ChannelNotificationManager.java


注:本文中的android.support.v4.app.NotificationCompat.DEFAULT_LIGHTS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。