List of usage examples for android.app NotificationChannel setLockscreenVisibility
public void setLockscreenVisibility(int lockscreenVisibility)
From source file:com.none.tom.simplerssreader.service.FeedUpdateBackgroundService.java
@SuppressWarnings({ "ConstantConditions", "deprecation" }) private static void showNotification(final Context context, final List<String> payload) { final NotificationManager manager = context.getSystemService(NotificationManager.class); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { final NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, NOTIFICATION_CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT); channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); channel.setBypassDnd(false);//w w w. j av a2 s . c o m channel.enableLights(true); channel.setShowBadge(true); channel.enableVibration(true); manager.createNotificationChannel(channel); } final PendingIntent intent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), PendingIntent.FLAG_UPDATE_CURRENT); final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle() .setBigContentTitle(context.getString(R.string.notification_title_big)); final int size = payload.size(); for (int i = 0; i < size; i++) { style.addLine(payload.get(i)); } manager.notify(ID_NOTIFICATION, new NotificationCompat.Builder(context) .setChannelId(NOTIFICATION_CHANNEL_ID).setSmallIcon(R.drawable.ic_rss_feed_white_24dp) .setContentTitle(context.getString(R.string.notification_title)) .setContentText(context.getString(R.string.notification_text)).setContentIntent(intent) .setStyle(style).setWhen(System.currentTimeMillis()).setAutoCancel(true).setShowWhen(true).build()); }
From source file:com.davidmiguel.gobees.utils.NotificationsHelper.java
@RequiresApi(Build.VERSION_CODES.O) private void createMonitoringChannel() { NotificationChannel channel = new NotificationChannel(MONITORING_CHANNEL, getString(R.string.not_channel_monitoring), NotificationManager.IMPORTANCE_LOW); channel.setDescription(getString(R.string.not_channel_monitoring_desc)); channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); channel.setShowBadge(false);//from www . j ava 2s .c o m channel.enableLights(false); getManager().createNotificationChannel(channel); }
From source file:com.google.android.gms.location.sample.backgroundlocationupdates.LocationResultHelper.java
LocationResultHelper(Context context, List<Location> locations) { mContext = context;/*from w w w.ja v a 2 s . co m*/ mLocations = locations; NotificationChannel channel = new NotificationChannel(PRIMARY_CHANNEL, context.getString(R.string.default_channel), NotificationManager.IMPORTANCE_DEFAULT); channel.setLightColor(Color.GREEN); channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE); getNotificationManager().createNotificationChannel(channel); }
From source file:chat.viska.android.Application.java
private void initializeNotificationChannels() { if (Build.VERSION.SDK_INT >= 26) { final NotificationManager manager = getSystemService(NotificationManager.class); final NotificationChannel systemChannel = new NotificationChannel(KEY_NOTIF_CHANNEL_SYSTEM, getString(R.string.title_notif_channel_system), NotificationManager.IMPORTANCE_LOW); systemChannel.setDescription(getString(R.string.desc_notif_channel_system)); systemChannel.enableVibration(false); systemChannel.enableLights(false); systemChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); systemChannel.setShowBadge(false); manager.createNotificationChannel(systemChannel); final NotificationChannel messagingChannel = new NotificationChannel(KEY_NOTIF_CHANNEL_MESSAGES, getString(R.string.title_notif_channel_messaging), NotificationManager.IMPORTANCE_HIGH); systemChannel.setDescription(getString(R.string.desc_notif_channel_messaging)); systemChannel.enableVibration(true); systemChannel.enableLights(true); systemChannel.setLockscreenVisibility(Notification.VISIBILITY_SECRET); systemChannel.setShowBadge(true); manager.createNotificationChannel(messagingChannel); }//from w ww . j a v a 2 s . c o m }
From source file:com.sxt.chat.utils.NotificationHelper.java
/** * ?/*ww w . j a v a 2s. c o m*/ * <p> * note : notify() ? ???,?? so, Create? */ public NotificationHelper(Context ctx) { super(ctx); context = ctx; soundUri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.notify_message); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { AudioAttributes att = new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_NOTIFICATION) .setContentType(AudioAttributes.CONTENT_TYPE_SPEECH).build(); NotificationChannel channel = new NotificationChannel(DEFAULT_CHANNEL, "Channel", NotificationManager.IMPORTANCE_HIGH); channel.setSound(soundUri, att); channel.setLightColor(Color.YELLOW); channel.setShowBadge(true); channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); getManager().createNotificationChannel(channel); NotificationChannel chanCustom = new NotificationChannel(CUSTOM_NOTIFY_CHANNEL, "Custom Layout Channel", NotificationManager.IMPORTANCE_HIGH); channel.setSound(soundUri, att); chanCustom.setLightColor(Color.RED); chanCustom.setShowBadge(true); chanCustom.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); getManager().createNotificationChannel(chanCustom); } }
From source file:com.giovanniterlingen.windesheim.controllers.NotificationController.java
public void initNotificationChannels() { if (android.os.Build.VERSION.SDK_INT >= 26) { NotificationChannel pushChannel = new NotificationChannel(PUSH_NOTIFICATION_CHANNEL, ApplicationLoader.applicationContext.getResources().getString(R.string.push_notification), NotificationManager.IMPORTANCE_HIGH); pushChannel.setDescription(ApplicationLoader.applicationContext.getResources() .getString(R.string.push_notification_description)); pushChannel.enableLights(true);/*from w ww .j ava 2s .c o m*/ pushChannel.enableVibration(true); pushChannel.setShowBadge(true); pushChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); NotificationChannel persistentChannel = new NotificationChannel(PERSISTENT_NOTIFICATION_CHANNEL, ApplicationLoader.applicationContext.getResources().getString(R.string.persistent_notification), NotificationManager.IMPORTANCE_MIN); persistentChannel.setDescription(ApplicationLoader.applicationContext.getResources() .getString(R.string.persistent_notification_description)); persistentChannel.enableLights(false); persistentChannel.enableVibration(false); persistentChannel.setShowBadge(false); persistentChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); NotificationChannel serviceChannel = new NotificationChannel(SERVICE_NOTIFICATION_CHANNEL, ApplicationLoader.applicationContext.getResources().getString(R.string.service_notification), NotificationManager.IMPORTANCE_MIN); serviceChannel.setDescription(ApplicationLoader.applicationContext.getResources() .getString(R.string.service_notification_description)); serviceChannel.enableLights(false); serviceChannel.enableVibration(false); serviceChannel.setShowBadge(false); serviceChannel.setLockscreenVisibility(Notification.VISIBILITY_SECRET); NotificationManager mManager = (NotificationManager) ApplicationLoader.applicationContext .getSystemService(Context.NOTIFICATION_SERVICE); mManager.createNotificationChannel(pushChannel); mManager.createNotificationChannel(persistentChannel); mManager.createNotificationChannel(serviceChannel); } }
From source file:org.restcomm.android.sdk.RCDevice.java
/** * Method returns the Notification builder * For Oreo devices we can have channels with HIGH and LOW importance. * If highImportance is true builder will be created with HIGH priority * For pre Oreo devices builder without channel will be returned * @param highImportance true if we need HIGH channel, false if we need LOW * @return/*from w w w . j a v a 2 s . co m*/ */ private NotificationCompat.Builder getNotificationBuilder(boolean highImportance) { NotificationCompat.Builder builder; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { if (highImportance) { NotificationChannel channel = new NotificationChannel(PRIMARY_CHANNEL_ID, PRIMARY_CHANNEL, NotificationManager.IMPORTANCE_HIGH); channel.setLightColor(Color.GREEN); channel.enableLights(true); channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); channel.enableVibration(true); channel.setVibrationPattern(notificationVibrationPattern); ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)) .createNotificationChannel(channel); builder = new NotificationCompat.Builder(RCDevice.this, PRIMARY_CHANNEL_ID); } else { NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); NotificationChannel notificationChannel = new NotificationChannel(DEFAULT_FOREGROUND_CHANNEL_ID, DEFAULT_FOREGROUND_CHANNEL, NotificationManager.IMPORTANCE_LOW); notificationManager.createNotificationChannel(notificationChannel); builder = new NotificationCompat.Builder(RCDevice.this, DEFAULT_FOREGROUND_CHANNEL_ID); } } else { builder = new NotificationCompat.Builder(RCDevice.this); } return builder; }