本文整理汇总了Java中android.support.v4.app.NotificationCompat.PRIORITY_HIGH属性的典型用法代码示例。如果您正苦于以下问题:Java NotificationCompat.PRIORITY_HIGH属性的具体用法?Java NotificationCompat.PRIORITY_HIGH怎么用?Java NotificationCompat.PRIORITY_HIGH使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.support.v4.app.NotificationCompat
的用法示例。
在下文中一共展示了NotificationCompat.PRIORITY_HIGH属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createOptInNotification
private void createOptInNotification(boolean highPriority) {
PendingIntent pendingIntent = createOptInIntent();
int priority = highPriority ? NotificationCompat.PRIORITY_HIGH
: NotificationCompat.PRIORITY_MIN;
// Get values to display.
Resources resources = mContext.getResources();
String title = resources.getString(R.string.physical_web_optin_notification_title);
String text = resources.getString(R.string.physical_web_optin_notification_text);
Bitmap largeIcon = BitmapFactory.decodeResource(resources, R.mipmap.app_icon);
// Create the notification.
Notification notification = new NotificationCompat.Builder(mContext)
.setLargeIcon(largeIcon)
.setSmallIcon(R.drawable.ic_physical_web_notification)
.setContentTitle(title)
.setContentText(text)
.setContentIntent(pendingIntent)
.setPriority(priority)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setAutoCancel(true)
.setLocalOnly(true)
.build();
mNotificationManager.notify(NotificationConstants.NOTIFICATION_ID_PHYSICAL_WEB,
notification);
}
示例2: MessagingStyleCommsAppData
private MessagingStyleCommsAppData() {
// Standard notification values
// Content for API <24 (M and below) devices
mContentTitle = "2 Messages w/ Famous McFamously";
mContentText = "Dude! ... You know I am a Pesce-pescetarian. :P";
mPriority = NotificationCompat.PRIORITY_HIGH;
// Style notification values
// For each message, you need the timestamp, in this case, we are using arbitrary ones.
long currentTime = System.currentTimeMillis();
mMessages = new ArrayList<>();
mMessages.add(
new MessagingStyle.Message(
"What are you doing tonight?", currentTime - 4000, "Famous"));
mMessages.add(
new MessagingStyle.Message(
"I don't know, dinner maybe?", currentTime - 3000, null));
mMessages.add(new MessagingStyle.Message("Sounds good.", currentTime - 2000, "Famous"));
mMessages.add(new MessagingStyle.Message("How about BBQ?", currentTime - 1000, null));
// Last two are the newest message (2) from friend
mMessages.add(new MessagingStyle.Message("Hey!", currentTime, "Famous"));
mMessages.add(
new MessagingStyle.Message(
"You know I am a Pesce-pescetarian. :P", currentTime, "Famous"));
// String version of the mMessages above
mFullConversation =
"Famous: What are you doing tonight?\n\n"
+ "Me: I don't know, dinner maybe?\n\n"
+ "Famous: Sounds good.\n\n"
+ "Me: How about BBQ?\n\n"
+ "Famous: Hey!\n\n"
+ "Famous: You know I am a Pesce-pescetarian. :P\n\n";
mNumberOfNewMessages = 2;
// Name preferred when replying to chat
mReplayName = "Me";
// If the phone is in "Do not disturb mode, the user will still be notified if
// the user(s) is starred as a favorite.
mParticipants = new ArrayList<>();
mParticipants.add("Famous McFamously");
// Notification channel values (for devices targeting 26 and above):
mChannelId = "channel_messaging_1";
// The user-visible name of the channel.
mChannelName = "Sample Messaging";
// The user-visible description of the channel.
mChannelDescription = "Sample Messaging Notifications";
mChannelImportance = NotificationManager.IMPORTANCE_MAX;
mChannelEnableVibrate = true;
mChannelLockscreenVisibility = NotificationCompat.VISIBILITY_PRIVATE;
}
示例3: getPriority
@Override
public int getPriority() {
return NotificationCompat.PRIORITY_HIGH;
}