當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。