Example usage for android.app NotificationManager createNotificationChannel

List of usage examples for android.app NotificationManager createNotificationChannel

Introduction

In this page you can find the example usage for android.app NotificationManager createNotificationChannel.

Prototype

public void createNotificationChannel(@NonNull NotificationChannel channel) 

Source Link

Document

Creates a notification channel that notifications can be posted to.

Usage

From source file:org.pocketworkstation.pckeyboard.LatinIME.java

private void createNotificationChannel() {
    // Create the NotificationChannel, but only on API 26+ because
    // the NotificationChannel class is new and not in the support library
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        CharSequence name = getString(R.string.notification_channel_name);
        String description = getString(R.string.notification_channel_description);
        int importance = NotificationManager.IMPORTANCE_LOW;
        NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, name, importance);
        channel.setDescription(description);
        // Register the channel with the system; you can't change the importance
        // or other notification behaviors after this
        NotificationManager notificationManager = getSystemService(NotificationManager.class);
        notificationManager.createNotificationChannel(channel);
    }//from   ww  w  .  j  av  a 2  s  .co m
}