本文整理匯總了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;
}