use of android.app.NotificationChannel in project Douya by DreaminginCodeZH.
the class MediaNotification method createNotificationChannel.
private void createNotificationChannel() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
return;
}
NotificationChannel channel = new NotificationChannel(mChannelId, mService.getString(mChannelNameRes), mChannelImportance);
channel.setDescription(mService.getString(mChannelDescriptionRes));
channel.setShowBadge(false);
getNotificationManager().createNotificationChannel(channel);
}
use of android.app.NotificationChannel in project kcanotify by antest1.
the class KcaService method createServiceChannel.
private void createServiceChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
int priority = IMPORTANCE_DEFAULT;
if (getBooleanPreferences(getApplicationContext(), PREF_KCA_SET_PRIORITY)) {
priority = IMPORTANCE_HIGH;
}
NotificationChannel channel = new NotificationChannel(getServiceChannelId(), SERVICE_CHANNEL_NAME, priority);
channel.enableVibration(false);
channel.setSound(null, null);
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
notifiManager.deleteNotificationChannel(SERVICE_CHANNEL_ID_OLD);
notifiManager.createNotificationChannel(channel);
}
}
use of android.app.NotificationChannel in project kcanotify by antest1.
the class KcaAlarmService method createAlarmChannel.
private void createAlarmChannel(String uri) {
Log.e("KCA-A", "recv: " + uri);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
String soundKind = getStringPreferences(getApplicationContext(), PREF_KCA_NOTI_SOUND_KIND);
boolean isVibrate = soundKind.equals(getString(R.string.sound_kind_value_mixed)) || soundKind.equals(getString(R.string.sound_kind_value_vibrate));
notificationManager.deleteNotificationChannel(ALARM_CHANNEL_ID);
while (!alarmChannelList.isEmpty()) {
notificationManager.deleteNotificationChannel(alarmChannelList.poll());
}
AudioAttributes.Builder attrs = new AudioAttributes.Builder();
attrs.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION);
attrs.setUsage(AudioAttributes.USAGE_NOTIFICATION);
String channel_name = createAlarmId(uri, isVibrate);
alarmChannelList.add(channel_name);
NotificationChannel channel = new NotificationChannel(alarmChannelList.peek(), getStringWithLocale(R.string.notification_appinfo_title), NotificationManager.IMPORTANCE_HIGH);
channel.setSound(Uri.parse(uri), attrs.build());
channel.enableVibration(isVibrate);
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
notificationManager.createNotificationChannel(channel);
}
}
use of android.app.NotificationChannel in project quickstart-android by firebase.
the class MyFirebaseMessagingService method sendNotification.
/**
* Create and show a simple notification containing the received FCM message.
*
* @param messageBody FCM message body received.
*/
private void sendNotification(String messageBody) {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, /* Request code */
intent, PendingIntent.FLAG_ONE_SHOT);
String channelId = getString(R.string.default_notification_channel_id);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId).setSmallIcon(R.drawable.ic_stat_ic_notification).setContentTitle(getString(R.string.fcm_message)).setContentText(messageBody).setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// Since android Oreo notification channel is needed.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(channelId, "Channel human readable title", NotificationManager.IMPORTANCE_DEFAULT);
notificationManager.createNotificationChannel(channel);
}
notificationManager.notify(0, /* ID of notification */
notificationBuilder.build());
}
use of android.app.NotificationChannel in project quickstart-android by firebase.
the class MyBaseTaskService method createDefaultChannel.
private void createDefaultChannel() {
// Since android Oreo notification channel is needed.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
NotificationChannel channel = new NotificationChannel(CHANNEL_ID_DEFAULT, "Default", NotificationManager.IMPORTANCE_DEFAULT);
nm.createNotificationChannel(channel);
}
}
Aggregations