Java Code Examples for androidx.core.app.NotificationCompat#PRIORITY_HIGH

The following examples show how to use androidx.core.app.NotificationCompat#PRIORITY_HIGH . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReactNativeUtil.java    From react-native-azurenotificationhub with MIT License 6 votes vote down vote up
public static int getNotificationCompatPriority(String priorityString) {
    int priority = NotificationCompat.PRIORITY_DEFAULT;
    if (priorityString != null) {
        switch (priorityString.toLowerCase()) {
            case REMOTE_NOTIFICATION_PRIORITY_MAX:
                priority = NotificationCompat.PRIORITY_MAX;
                break;
            case REMOTE_NOTIFICATION_PRIORITY_HIGH:
                priority = NotificationCompat.PRIORITY_HIGH;
                break;
            case REMOTE_NOTIFICATION_PRIORITY_LOW:
                priority = NotificationCompat.PRIORITY_LOW;
                break;
            case REMOTE_NOTIFICATION_PRIORITY_MIN:
                priority = NotificationCompat.PRIORITY_MIN;
                break;
            case REMOTE_NOTIFICATION_PRIORITY_NORMAL:
                priority = NotificationCompat.PRIORITY_DEFAULT;
                break;
        }
    }

    return priority;
}
 
Example 2
Source File: MockDatabase.java    From user-interface-samples with Apache License 2.0 5 votes vote down vote up
private BigPictureStyleSocialAppData() {
    // Standard Notification values:
    // Title/Content for API <16 (4.0 and below) devices.
    mContentTitle = "Bob's Post";
    mContentText = "[Picture] Like my shot of Earth?";
    mPriority = NotificationCompat.PRIORITY_HIGH;

    // Style notification values:
    mBigImage = R.drawable.earth;
    mBigContentTitle = "Bob's Post";
    mSummaryText = "Like my shot of Earth?";

    // This would be possible responses based on the contents of the post.
    mPossiblePostResponses = new CharSequence[] {"Yes", "No", "Maybe?"};

    mParticipants = new ArrayList<>();
    mParticipants.add("Bob Smith");

    // Notification channel values (for devices targeting 26 and above):
    mChannelId = "channel_social_1";
    // The user-visible name of the channel.
    mChannelName = "Sample Social";
    // The user-visible description of the channel.
    mChannelDescription = "Sample Social Notifications";
    mChannelImportance = NotificationManager.IMPORTANCE_HIGH;
    mChannelEnableVibrate = true;
    mChannelLockscreenVisibility = NotificationCompat.VISIBILITY_PRIVATE;
}
 
Example 3
Source File: NotificationBuilder.java    From libcommon with Apache License 2.0 5 votes vote down vote up
/**
 * Notification生成用のファクトリーメソッド
 * @return
 */
@SuppressLint("InlinedApi")
public Notification build() {
	if (mChannelBuilder.getImportance() == NotificationManager.IMPORTANCE_NONE) {
		// importanceが設定されていないときでmPriorityがセットされていればそれに従う
		switch (mPriority) {
		case NotificationCompat.PRIORITY_MIN:
			mChannelBuilder.setImportance(NotificationManager.IMPORTANCE_MIN);
			break;
		case NotificationCompat.PRIORITY_LOW:
			mChannelBuilder.setImportance(NotificationManager.IMPORTANCE_LOW);
			break;
		case NotificationCompat.PRIORITY_DEFAULT:
			mChannelBuilder.setImportance(NotificationManager.IMPORTANCE_DEFAULT);
			break;
		case NotificationCompat.PRIORITY_HIGH:
			mChannelBuilder.setImportance(NotificationManager.IMPORTANCE_HIGH);
			break;
		case NotificationCompat.PRIORITY_MAX:
			mChannelBuilder.setImportance(NotificationManager.IMPORTANCE_HIGH);
			break;
		default:
			// ChannelBuilder側の設定に従う==IMPORTANCE_DEFAULT
			break;
		}
	}
	mChannelBuilder.build();
	super.setContentIntent(createContentIntent());
	super.setDeleteIntent(createDeleteIntent());
	super.setFullScreenIntent(createFullScreenIntent(), isHighPriorityFullScreenIntent());
	return super.build();
}
 
Example 4
Source File: MockDatabase.java    From android-Notifications with Apache License 2.0 5 votes vote down vote up
private BigPictureStyleSocialAppData() {
    // Standard Notification values:
    // Title/Content for API <16 (4.0 and below) devices.
    mContentTitle = "Bob's Post";
    mContentText = "[Picture] Like my shot of Earth?";
    mPriority = NotificationCompat.PRIORITY_HIGH;

    // Style notification values:
    mBigImage = R.drawable.earth;
    mBigContentTitle = "Bob's Post";
    mSummaryText = "Like my shot of Earth?";

    // This would be possible responses based on the contents of the post.
    mPossiblePostResponses = new CharSequence[] {"Yes", "No", "Maybe?"};

    mParticipants = new ArrayList<>();
    mParticipants.add("Bob Smith");

    // Notification channel values (for devices targeting 26 and above):
    mChannelId = "channel_social_1";
    // The user-visible name of the channel.
    mChannelName = "Sample Social";
    // The user-visible description of the channel.
    mChannelDescription = "Sample Social Notifications";
    mChannelImportance = NotificationManager.IMPORTANCE_HIGH;
    mChannelEnableVibrate = true;
    mChannelLockscreenVisibility = NotificationCompat.VISIBILITY_PRIVATE;
}
 
Example 5
Source File: MockDatabase.java    From wear-os-samples with Apache License 2.0 4 votes vote down vote up
private MessagingStyleCommsAppData(Context context) {
    // Standard notification values:
    // Content for API <24 (M and below) devices.
    // Note: I am actually hardcoding these Strings based on info below. You would be
    // pulling these values from the same source in your database. I leave this up here, so
    // you can see the standard parts of a Notification first.
    mContentTitle = "3 Messages w/ Famous, Wendy";
    mContentText = "HEY, I see my house! :)";
    mPriority = NotificationCompat.PRIORITY_HIGH;

    // Create the users for the conversation.
    // Name preferred when replying to chat.
    mMe =
            new Person.Builder()
                    .setName("Me MacDonald")
                    .setKey("1234567890")
                    .setUri("tel:1234567890")
                    .setIcon(
                            IconCompat.createWithResource(context, R.drawable.me_macdonald))
                    .build();

    Person participant1 =
            new Person.Builder()
                    .setName("Famous Fryer")
                    .setKey("9876543210")
                    .setUri("tel:9876543210")
                    .setIcon(
                            IconCompat.createWithResource(context, R.drawable.famous_fryer))
                    .build();

    Person participant2 =
            new Person.Builder()
                    .setName("Wendy Wonda")
                    .setKey("2233221122")
                    .setUri("tel:2233221122")
                    .setIcon(IconCompat.createWithResource(context, R.drawable.wendy_wonda))
                    .build();

    // If the phone is in "Do not disturb mode, the user will still be notified if
    // the user(s) is starred as a favorite.
    // Note: You don't need to add yourself, aka 'me', as a participant.
    mParticipants = new ArrayList<>();
    mParticipants.add(participant1);
    mParticipants.add(participant2);

    mMessages = new ArrayList<>();

    // For each message, you need the timestamp. In this case, we are using arbitrary longs
    // representing time in milliseconds.
    mMessages.add(
            // When you are setting an image for a message, text does not display.
            new MessagingStyle.Message("", 1528490641998L, participant1)
                    .setData(
                            "image/png", resourceToUri(context, R.drawable.earth)));

    mMessages.add(
            new MessagingStyle.Message(
                    "Visiting the moon again? :P", 1528490643998L, mMe));

    mMessages.add(
            new MessagingStyle.Message(
                    "HEY, I see my house!", 1528490645998L, participant2));

    // String version of the mMessages above.
    mFullConversation =
            "Famous: [Picture of Moon]\n\n"
                    + "Me: Visiting the moon again? :P\n\n"
                    + "Wendy: HEY, I see my house! :)\n\n";

    // Responses based on the last messages of the conversation. You would use
    // Machine Learning to get these (https://developers.google.com/ml-kit/).
    mReplyChoicesBasedOnLastMessages =
            new CharSequence[] {"Me too!", "How's the weather?", "You have good eyesight."};

    // 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;
}
 
Example 6
Source File: MockDatabase.java    From user-interface-samples with Apache License 2.0 4 votes vote down vote up
private MessagingStyleCommsAppData(Context context) {
    // Standard notification values:
    // Content for API <24 (M and below) devices.
    // Note: I am actually hardcoding these Strings based on info below. You would be
    // pulling these values from the same source in your database. I leave this up here, so
    // you can see the standard parts of a Notification first.
    mContentTitle = "3 Messages w/ Famous, Wendy";
    mContentText = "HEY, I see my house! :)";
    mPriority = NotificationCompat.PRIORITY_HIGH;

    // Create the users for the conversation.
    // Name preferred when replying to chat.
    mMe =
            new Person.Builder()
                    .setName("Me MacDonald")
                    .setKey("1234567890")
                    .setUri("tel:1234567890")
                    .setIcon(
                            IconCompat.createWithResource(context, R.drawable.me_macdonald))
                    .build();

    Person participant1 =
            new Person.Builder()
                    .setName("Famous Frank")
                    .setKey("9876543210")
                    .setUri("tel:9876543210")
                    .setIcon(
                            IconCompat.createWithResource(context, R.drawable.famous_fryer))
                    .build();

    Person participant2 =
            new Person.Builder()
                    .setName("Wendy Weather")
                    .setKey("2233221122")
                    .setUri("tel:2233221122")
                    .setIcon(IconCompat.createWithResource(context, R.drawable.wendy_wonda))
                    .build();

    // If the phone is in "Do not disturb mode, the user will still be notified if
    // the user(s) is starred as a favorite.
    // Note: You don't need to add yourself, aka 'me', as a participant.
    mParticipants = new ArrayList<>();
    mParticipants.add(participant1);
    mParticipants.add(participant2);

    mMessages = new ArrayList<>();

    // For each message, you need the timestamp. In this case, we are using arbitrary longs
    // representing time in milliseconds.
    mMessages.add(
            // When you are setting an image for a message, text does not display.
            new MessagingStyle.Message("", 1528490641998l, participant1)
                    .setData("image/png", resourceToUri(context, R.drawable.earth)));

    mMessages.add(
            new MessagingStyle.Message(
                    "Visiting the moon again? :P", 1528490643998l, mMe));

    mMessages.add(
            new MessagingStyle.Message("HEY, I see my house!", 1528490645998l, participant2));

    // String version of the mMessages above.
    mFullConversation =
            "Famous: [Picture of Moon]\n\n"
                    + "Me: Visiting the moon again? :P\n\n"
                    + "Wendy: HEY, I see my house! :)\n\n";

    // Responses based on the last messages of the conversation. You would use
    // Machine Learning to get these (https://developers.google.com/ml-kit/).
    mReplyChoicesBasedOnLastMessages =
            new CharSequence[] {"Me too!", "How's the weather?", "You have good eyesight."};

    // 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;
}
 
Example 7
Source File: NotificationData.java    From Status with Apache License 2.0 4 votes vote down vote up
public boolean shouldShowHeadsUp(Context context) {
    return //(boolean) PreferenceData.STATUS_NOTIFICATIONS_HEADS_UP.getValue(context) && TODO: #137
            (priority >= NotificationCompat.PRIORITY_HIGH || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) && isAlert;
}
 
Example 8
Source File: NotificationData.java    From Status with Apache License 2.0 4 votes vote down vote up
public boolean shouldHideStatusBar() {
    return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && priority >= NotificationCompat.PRIORITY_HIGH && isAlert;
}
 
Example 9
Source File: MockDatabase.java    From android-Notifications with Apache License 2.0 4 votes vote down vote up
private MessagingStyleCommsAppData(Context context) {
    // Standard notification values:
    // Content for API <24 (M and below) devices.
    // Note: I am actually hardcoding these Strings based on info below. You would be
    // pulling these values from the same source in your database. I leave this up here, so
    // you can see the standard parts of a Notification first.
    mContentTitle = "3 Messages w/ Famous, Wendy";
    mContentText = "HEY, I see my house! :)";
    mPriority = NotificationCompat.PRIORITY_HIGH;

    // Create the users for the conversation.
    // Name preferred when replying to chat.
    mMe =
            new Person.Builder()
                    .setName("Me MacDonald")
                    .setKey("1234567890")
                    .setUri("tel:1234567890")
                    .setIcon(
                            IconCompat.createWithResource(context, R.drawable.me_macdonald))
                    .build();

    Person participant1 =
            new Person.Builder()
                    .setName("Famous Fryer")
                    .setKey("9876543210")
                    .setUri("tel:9876543210")
                    .setIcon(
                            IconCompat.createWithResource(context, R.drawable.famous_fryer))
                    .build();

    Person participant2 =
            new Person.Builder()
                    .setName("Wendy Wonda")
                    .setKey("2233221122")
                    .setUri("tel:2233221122")
                    .setIcon(IconCompat.createWithResource(context, R.drawable.wendy_wonda))
                    .build();

    // If the phone is in "Do not disturb mode, the user will still be notified if
    // the user(s) is starred as a favorite.
    // Note: You don't need to add yourself, aka 'me', as a participant.
    mParticipants = new ArrayList<>();
    mParticipants.add(participant1);
    mParticipants.add(participant2);

    mMessages = new ArrayList<>();

    // For each message, you need the timestamp. In this case, we are using arbitrary longs
    // representing time in milliseconds.
    mMessages.add(
            // When you are setting an image for a message, text does not display.
            new MessagingStyle.Message("", 1528490641998l, participant1)
                    .setData("image/png", resourceToUri(context, R.drawable.earth)));

    mMessages.add(
            new MessagingStyle.Message(
                    "Visiting the moon again? :P", 1528490643998l, mMe));

    mMessages.add(
            new MessagingStyle.Message("HEY, I see my house!", 1528490645998l, participant2));

    // String version of the mMessages above.
    mFullConversation =
            "Famous: [Picture of Moon]\n\n"
                    + "Me: Visiting the moon again? :P\n\n"
                    + "Wendy: HEY, I see my house! :)\n\n";

    // Responses based on the last messages of the conversation. You would use
    // Machine Learning to get these (https://developers.google.com/ml-kit/).
    mReplyChoicesBasedOnLastMessages =
            new CharSequence[] {"Me too!", "How's the weather?", "You have good eyesight."};

    // 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;
}