當前位置: 首頁>>代碼示例>>Java>>正文


Java NotificationCompat.PRIORITY_HIGH屬性代碼示例

本文整理匯總了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);
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:27,代碼來源:UrlManager.java

示例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;
}
 
開發者ID:googlesamples,項目名稱:android-WearAccessibilityApp,代碼行數:56,代碼來源:MockDatabase.java

示例3: getPriority

@Override
public int getPriority() {
    return NotificationCompat.PRIORITY_HIGH;
}
 
開發者ID:cfryan1990,項目名稱:NotificationCompat,代碼行數:4,代碼來源:DefaultConfig.java


注:本文中的android.support.v4.app.NotificationCompat.PRIORITY_HIGH屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。