List of usage examples for android.app NotificationManager IMPORTANCE_MIN
int IMPORTANCE_MIN
To view the source code for android.app NotificationManager IMPORTANCE_MIN.
Click Source Link
From source file:com.ubergeek42.WeechatAndroid.service.Notificator.java
@MainThread public static void init(Context c) { context = c.getApplicationContext(); manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return;//www . j a v a 2 s.c o m NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_CONNECTION_STATUS, context.getString(R.string.notification_channel_connection_status), NotificationManager.IMPORTANCE_MIN); channel.setShowBadge(false); manager.createNotificationChannel(channel); channel = new NotificationChannel(NOTIFICATION_CHANNEL_HOTLIST, context.getString(R.string.notification_channel_hotlist), NotificationManager.IMPORTANCE_DEFAULT); manager.createNotificationChannel(channel); }
From source file:org.iota.wallet.helper.NotificationHelper.java
@RequiresApi(api = Build.VERSION_CODES.O) private static void createNotificationChannel(Context context) { NotificationManager notificationManager = context.getSystemService(NotificationManager.class); NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL, context.getResources().getString(R.string.app_name), NotificationManager.IMPORTANCE_MIN); notificationManager.createNotificationChannel(channel); }
From source file:com.commonsware.android.service.lifecycle.DemoService.java
@TargetApi(Build.VERSION_CODES.O) private void initChannels() { NotificationChannel channel = new NotificationChannel(CHANNEL_MIN, getString(R.string.channel_min), NotificationManager.IMPORTANCE_MIN); mgr.createNotificationChannel(channel); channel = new NotificationChannel(CHANNEL_LOW, getString(R.string.channel_low), NotificationManager.IMPORTANCE_LOW); mgr.createNotificationChannel(channel); }
From source file:arun.com.chromer.appdetect.AppDetectService.java
private void initChannels() { if (Utils.ANDROID_OREO) { NotificationChannel channel = new NotificationChannel(CHANNEL_ID, "App Detection Service", NotificationManager.IMPORTANCE_MIN); channel.setDescription(getString(R.string.app_detection_notification_channel_description)); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.createNotificationChannel(channel); }// www .j a v a2 s . co m }
From source file:org.mozilla.focus.session.SessionNotificationService.java
public void createNotificationChannelIfNeeded() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { // Notification channels are only available on Android O or higher. return;/*from ww w. ja v a 2s . c o m*/ } final NotificationManager notificationManager = getSystemService(NotificationManager.class); if (notificationManager == null) { return; } final String notificationChannelName = getString(R.string.notification_browsing_session_channel_name); final String notificationChannelDescription = getString( R.string.notification_browsing_session_channel_description, getString(R.string.app_name)); final NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, notificationChannelName, NotificationManager.IMPORTANCE_MIN); channel.setImportance(NotificationManager.IMPORTANCE_LOW); channel.setDescription(notificationChannelDescription); channel.enableLights(false); channel.enableVibration(false); channel.setShowBadge(true); notificationManager.createNotificationChannel(channel); }
From source file:com.frostwire.android.gui.NotificationUpdateDemon.java
private void updatePermanentStatusNotification() { if (!ConfigurationManager.instance() .getBoolean(Constants.PREF_KEY_GUI_ENABLE_PERMANENT_STATUS_NOTIFICATION)) { return;/*from w w w .jav a 2 s. c o m*/ } if (notificationViews == null || notificationObject == null) { LOG.warn("Notification views or object are null, review your logic"); return; } // number of uploads (seeding) and downloads TransferManager transferManager; try { transferManager = TransferManager.instance(); } catch (IllegalStateException btEngineNotReadyException) { return; } if (transferManager != null) { int downloads = transferManager.getActiveDownloads(); int uploads = transferManager.getActiveUploads(); if (downloads == 0 && uploads == 0) { NotificationManager manager = (NotificationManager) mParentContext .getSystemService(Context.NOTIFICATION_SERVICE); if (manager != null) { try { manager.cancel(Constants.NOTIFICATION_FROSTWIRE_STATUS); } catch (SecurityException ignored) { // possible java.lang.SecurityException } } return; // quick return } // format strings String sDown = UIUtils.rate2speed(transferManager.getDownloadsBandwidth() / 1024); String sUp = UIUtils.rate2speed(transferManager.getUploadsBandwidth() / 1024); // Transfers status. notificationViews.setTextViewText(R.id.view_permanent_status_text_downloads, downloads + " @ " + sDown); notificationViews.setTextViewText(R.id.view_permanent_status_text_uploads, uploads + " @ " + sUp); final NotificationManager notificationManager = (NotificationManager) mParentContext .getSystemService(Context.NOTIFICATION_SERVICE); if (notificationManager != null) { try { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { NotificationChannel channel = new NotificationChannel( Constants.FROSTWIRE_NOTIFICATION_CHANNEL_ID, "FrostWire", NotificationManager.IMPORTANCE_MIN); channel.setSound(null, null); notificationManager.createNotificationChannel(channel); } notificationManager.notify(Constants.NOTIFICATION_FROSTWIRE_STATUS, notificationObject); } catch (SecurityException ignored) { // possible java.lang.SecurityException ignored.printStackTrace(); } catch (Throwable ignored2) { // possible android.os.TransactionTooLargeException ignored2.printStackTrace(); } } } }
From source file:arun.com.chromer.webheads.WebHeadService.java
@NonNull @Override/*from w w w . j a v a2 s . co m*/ public Notification getNotification() { if (Utils.ANDROID_OREO) { final NotificationChannel channel = new NotificationChannel(WebHeadService.class.getName(), getString(R.string.web_heads_service), NotificationManager.IMPORTANCE_MIN); channel.setDescription(getString(R.string.app_detection_notification_channel_description)); final NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); if (notificationManager != null) { notificationManager.createNotificationChannel(channel); } } final PendingIntent contentIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_STOP_WEBHEAD_SERVICE), FLAG_UPDATE_CURRENT); final PendingIntent contextActivity = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_OPEN_CONTEXT_ACTIVITY), FLAG_UPDATE_CURRENT); final PendingIntent newTab = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_OPEN_NEW_TAB), FLAG_UPDATE_CURRENT); Notification notification = new NotificationCompat.Builder(this, WebHeadService.class.getName()) .setSmallIcon(R.drawable.ic_chromer_notification).setPriority(PRIORITY_MIN) .setContentText(getString(R.string.tap_close_all)) .setColor(ContextCompat.getColor(this, R.color.colorPrimary)) .addAction(R.drawable.ic_add, getText(R.string.open_new_tab), newTab) .addAction(R.drawable.ic_list, getText(R.string.manage), contextActivity) .setContentTitle(getString(R.string.web_heads_service)).setContentIntent(contentIntent) .setAutoCancel(false).setLocalOnly(true).build(); notification.flags |= Notification.FLAG_FOREGROUND_SERVICE; return notification; }
From source file:im.vector.notifications.NotificationUtils.java
/** * Add a notification groups./*from ww w .jav a 2 s . c om*/ * * @param context the context */ @SuppressLint("NewApi") public static void addNotificationChannels(Context context) { if (Build.VERSION.SDK_INT < 26) { return; } if (null == NOISY_NOTIFICATION_CHANNEL_NAME) { NOISY_NOTIFICATION_CHANNEL_NAME = context.getString(R.string.notification_noisy_notifications); } if (null == SILENT_NOTIFICATION_CHANNEL_NAME) { SILENT_NOTIFICATION_CHANNEL_NAME = context.getString(R.string.notification_silent_notifications); } if (null == CALL_NOTIFICATION_CHANNEL_NAME) { CALL_NOTIFICATION_CHANNEL_NAME = context.getString(R.string.call); } if (null == LISTEN_FOR_EVENTS_NOTIFICATION_CHANNEL_NAME) { LISTEN_FOR_EVENTS_NOTIFICATION_CHANNEL_NAME = context .getString(R.string.notification_listen_for_events); } NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); // A notification channel cannot be updated : // it must be deleted and created with another channel id if ((null == NOISY_NOTIFICATION_CHANNEL_ID)) { List<NotificationChannel> channels = notificationManager.getNotificationChannels(); for (NotificationChannel channel : channels) { if (channel.getId().startsWith(NOISY_NOTIFICATION_CHANNEL_ID_BASE)) { NOISY_NOTIFICATION_CHANNEL_ID = channel.getId(); } } } if (null != NOISY_NOTIFICATION_CHANNEL_ID) { NotificationChannel channel = notificationManager.getNotificationChannel(NOISY_NOTIFICATION_CHANNEL_ID); Uri notificationSound = channel.getSound(); Uri expectedSound = PreferencesManager.getNotificationRingTone(context); // the notification sound has been updated // need to delete it, to create a new one // else the sound won't be updated if (((null == notificationSound) ^ (null == expectedSound)) || ((null != notificationSound) && !TextUtils.equals(notificationSound.toString(), expectedSound.toString()))) { notificationManager.deleteNotificationChannel(NOISY_NOTIFICATION_CHANNEL_ID); NOISY_NOTIFICATION_CHANNEL_ID = null; } } if (null == NOISY_NOTIFICATION_CHANNEL_ID) { NOISY_NOTIFICATION_CHANNEL_ID = NOISY_NOTIFICATION_CHANNEL_ID_BASE + System.currentTimeMillis(); NotificationChannel channel = new NotificationChannel(NOISY_NOTIFICATION_CHANNEL_ID, NOISY_NOTIFICATION_CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT); channel.setDescription(NOISY_NOTIFICATION_CHANNEL_NAME); channel.setSound(PreferencesManager.getNotificationRingTone(context), null); channel.enableVibration(true); notificationManager.createNotificationChannel(channel); } if (null == notificationManager.getNotificationChannel(SILENT_NOTIFICATION_CHANNEL_NAME)) { NotificationChannel channel = new NotificationChannel(SILENT_NOTIFICATION_CHANNEL_ID, SILENT_NOTIFICATION_CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT); channel.setDescription(SILENT_NOTIFICATION_CHANNEL_NAME); channel.setSound(null, null); notificationManager.createNotificationChannel(channel); } if (null == notificationManager.getNotificationChannel(LISTEN_FOR_EVENTS_NOTIFICATION_CHANNEL_ID)) { NotificationChannel channel = new NotificationChannel(LISTEN_FOR_EVENTS_NOTIFICATION_CHANNEL_ID, LISTEN_FOR_EVENTS_NOTIFICATION_CHANNEL_NAME, NotificationManager.IMPORTANCE_MIN); channel.setDescription(LISTEN_FOR_EVENTS_NOTIFICATION_CHANNEL_NAME); channel.setSound(null, null); notificationManager.createNotificationChannel(channel); } if (null == notificationManager.getNotificationChannel(CALL_NOTIFICATION_CHANNEL_ID)) { NotificationChannel channel = new NotificationChannel(CALL_NOTIFICATION_CHANNEL_ID, CALL_NOTIFICATION_CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT); channel.setDescription(CALL_NOTIFICATION_CHANNEL_NAME); channel.setSound(null, null); notificationManager.createNotificationChannel(channel); } }
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 a va 2 s . com*/ 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:com.frostwire.android.gui.services.EngineService.java
public void notifyDownloadFinished(String displayName, File file, String infoHash) { try {//from w ww . j ava2s .com if (notifiedStorage.contains(infoHash)) { // already notified return; } else { notifiedStorage.add(infoHash); } Context context = getApplicationContext(); Intent i = new Intent(context, MainActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); i.putExtra(Constants.EXTRA_DOWNLOAD_COMPLETE_NOTIFICATION, true); i.putExtra(Constants.EXTRA_DOWNLOAD_COMPLETE_PATH, file.getAbsolutePath()); PendingIntent pi = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_UPDATE_CURRENT); NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new NotificationCompat.Builder(context, Constants.FROSTWIRE_NOTIFICATION_CHANNEL_ID).setWhen(System.currentTimeMillis()) .setContentText(getString(R.string.download_finished)) .setContentTitle(getString(R.string.download_finished)) .setSmallIcon(getNotificationIcon()).setContentIntent(pi).build(); notification.vibrate = ConfigurationManager.instance().vibrateOnFinishedDownload() ? VENEZUELAN_VIBE : null; notification.number = TransferManager.instance().getDownloadsToReview(); notification.flags |= Notification.FLAG_AUTO_CANCEL; if (manager != null) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { NotificationChannel channel = new NotificationChannel( Constants.FROSTWIRE_NOTIFICATION_CHANNEL_ID, "FrostWire", NotificationManager.IMPORTANCE_MIN); channel.setSound(null, null); manager.createNotificationChannel(channel); } manager.notify(Constants.NOTIFICATION_DOWNLOAD_TRANSFER_FINISHED, notification); } } catch (Throwable e) { LOG.error("Error creating notification for download finished", e); } }