本文整理汇总了Java中android.support.v4.app.NotificationCompat.PRIORITY_DEFAULT属性的典型用法代码示例。如果您正苦于以下问题:Java NotificationCompat.PRIORITY_DEFAULT属性的具体用法?Java NotificationCompat.PRIORITY_DEFAULT怎么用?Java NotificationCompat.PRIORITY_DEFAULT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.support.v4.app.NotificationCompat
的用法示例。
在下文中一共展示了NotificationCompat.PRIORITY_DEFAULT属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBuilder
/**
* 返回一个设置了 SmallIcon 等任何通知都相同的属性的 NotificationCompat.Builder
* 同时设置浮动通知 / LED / 震动等
*
* @param chat 聊天内容
*
* @return NotificationCompat.Builder
**/
@Override
public NotificationCompat.Builder createBuilder(Context context, @Nullable Chat chat) {
Profile profile = FFMSettings.getProfile();
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_GROUPS)
.setColor(context.getColor(profile.getNotificationColor()))
.setSmallIcon(profile.getNotificationIcon())
.setVisibility(Notification.VISIBILITY_PRIVATE);
if (FFMApplication.get(context).isSystem()) {
Bundle extras = new Bundle();
extras.putString("android.substName", context.getString(profile.getDisplayName()));
builder.addExtras(extras);
}
if (chat == null) {
return builder;
}
// @ 消息当作好友消息处理
boolean isFriend = chat.isFriend() || (chat.isGroup() && chat.getLatestMessage().isAt());
if (isFriend) {
builder.setChannelId(NOTIFICATION_CHANNEL_FRIENDS);
}
// support library still set them on O
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
// sound
builder.setSound(FFMSettings.getNotificationSound(!isFriend));
// priority
int priority = FFMSettings.getNotificationPriority(!isFriend);
builder.setPriority(priority);
// vibrate
int vibrate = FFMSettings.getNotificationVibrate(!isFriend);
switch (vibrate) {
case Vibrate.DISABLED:
break;
case Vibrate.DEFAULT:
builder.setDefaults(NotificationCompat.DEFAULT_VIBRATE);
break;
case Vibrate.SHORT:
builder.setVibrate(new long[]{0, 100, 0, 100});
break;
case Vibrate.LONG:
builder.setVibrate(new long[]{0, 1000});
break;
}
// lights
if (FFMSettings.getNotificationLight(!isFriend)
&& priority >= NotificationCompat.PRIORITY_DEFAULT) {
builder.setLights(context.getColor(R.color.colorNotification), 1000, 1000);
}
}
return builder;
}
示例2: getPriority
public int getPriority() {
return NotificationCompat.PRIORITY_DEFAULT;
}