本文整理汇总了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());
}