List of usage examples for android.app NotificationManager IMPORTANCE_DEFAULT
int IMPORTANCE_DEFAULT
To view the source code for android.app NotificationManager IMPORTANCE_DEFAULT.
Click Source Link
From source file:org.odk.collect.android.utilities.NotificationUtils.java
public static void createNotificationChannel(Collect collect) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationManager notificationManager = collect.getSystemService(NotificationManager.class); if (notificationManager != null) { notificationManager.createNotificationChannel( new NotificationChannel(CHANNEL_ID, collect.getString(R.string.notification_channel_name), NotificationManager.IMPORTANCE_DEFAULT)); }/*www . j a va2s . c o m*/ } }
From source file:com.google.android.gms.location.sample.backgroundlocationupdates.LocationResultHelper.java
LocationResultHelper(Context context, List<Location> locations) { mContext = context;//w w w.j a v a2 s. c o 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: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;/*from w w w .ja v a2 s . co 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:com.commonsware.android.sawmonitor.SAWDetector.java
static void seeSAW(Context ctxt, String pkg, String operation) { if (hasSAW(ctxt, pkg)) { Uri pkgUri = Uri.parse("package:" + pkg); Intent manage = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION); manage.setData(pkgUri);//from w w w . j a v a 2s. com Intent whitelist = new Intent(ctxt, WhitelistReceiver.class); whitelist.setData(pkgUri); Intent main = new Intent(ctxt, MainActivity.class); main.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); NotificationManager mgr = (NotificationManager) ctxt.getSystemService(Context.NOTIFICATION_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && mgr.getNotificationChannel(CHANNEL_WHATEVER) == null) { mgr.createNotificationChannel(new NotificationChannel(CHANNEL_WHATEVER, "Whatever", NotificationManager.IMPORTANCE_DEFAULT)); } NotificationCompat.Builder b = new NotificationCompat.Builder(ctxt, CHANNEL_WHATEVER); String text = String.format(ctxt.getString(R.string.msg_requested), operation, pkg); b.setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL).setWhen(System.currentTimeMillis()) .setContentTitle(ctxt.getString(R.string.msg_detected)).setContentText(text) .setSmallIcon(android.R.drawable.stat_notify_error) .setTicker(ctxt.getString(R.string.msg_detected)) .setContentIntent(PendingIntent.getActivity(ctxt, 0, manage, PendingIntent.FLAG_UPDATE_CURRENT)) .addAction(R.drawable.ic_verified_user_24dp, ctxt.getString(R.string.msg_whitelist), PendingIntent.getBroadcast(ctxt, 0, whitelist, 0)) .addAction(R.drawable.ic_settings_24dp, ctxt.getString(R.string.msg_settings), PendingIntent.getActivity(ctxt, 0, main, 0)); mgr.notify(NOTIFY_ID, b.build()); } }
From source file:com.commonsware.android.bluetooth.rxecho.ShoutingEchoService.java
@Override public void onCreate() { super.onCreate(); rxBluetooth = new RxBluetooth(getApplicationContext()); acceptConnections();/*from w ww . j a v a2s . c om*/ NotificationManager mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && mgr.getNotificationChannel(CHANNEL_WHATEVER) == null) { mgr.createNotificationChannel( new NotificationChannel(CHANNEL_WHATEVER, "Whatever", NotificationManager.IMPORTANCE_DEFAULT)); } startForeground(1338, buildForegroundNotification()); STATUS.postValue(Status.IS_RUNNING); }
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);/*from w ww.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:ti.modules.titanium.android.notificationmanager.NotificationManagerModule.java
@SuppressLint("NewApi") public static boolean useDefaultChannel() { // use default channel if we are targeting API 26+ boolean useDefaultChannel = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && TiApplication.getInstance().getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.O; // setup default channel it it does not exist if (useDefaultChannel && defaultChannel == null) { defaultChannel = new NotificationChannel(DEFAULT_CHANNEL_ID, "miscellaneous", NotificationManager.IMPORTANCE_DEFAULT); getManager().createNotificationChannel(defaultChannel); Log.w(TAG,/*from ww w . j a v a 2 s .c o m*/ "Falling back to default notification channel.\nIt is highly advised to create your own notification channel using Ti.Android.NotificationManager.createNotificationChannel()"); } return useDefaultChannel; }
From source file:de.aw.awlib.AWNotification.java
/** * @param context Context/*from w ww. j av a 2 s . c om*/ * @param contentTitle 1. Zeile der Notification */ public AWNotification(@NonNull Context context, @NonNull String contentTitle) { this.context = context; this.contentTitle = contentTitle; mNotifyID = lastNotifyID; lastNotifyID++; mChannelID = ((AWApplication) context.getApplicationContext()).getNotficationChannelID(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { mNotificationChannel = new NotificationChannel(mChannelID, "Nachricht", NotificationManager.IMPORTANCE_DEFAULT); } else { mNotificationChannel = null; } }
From source file:kr.ds.mymunsang.MyFirebaseMessagingService.java
private void sendNotification(String message, Bitmap bitmap) { Intent intent = new Intent(this, MainActivity2.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.channel_message_id); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId) .setPriority(NotificationCompat.PRIORITY_MAX).setSmallIcon(R.drawable.icon) .setContentTitle(getString(R.string.app_name)).setContentText(message).setAutoCancel(true) .setSound(defaultSoundUri).setContentIntent(pendingIntent); if (bitmap != null) { NotificationCompat.BigPictureStyle style = new NotificationCompat.BigPictureStyle(); style.setBigContentTitle(getString(R.string.app_name)); style.setSummaryText(message);/*from w ww .j a va 2 s . c o m*/ style.bigPicture(bitmap); notificationBuilder.setStyle(style); } 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, getString(R.string.channel_message_id), NotificationManager.IMPORTANCE_DEFAULT); channel.setDescription(getString(R.string.channel_message)); notificationManager.createNotificationChannel(channel); } notificationManager.notify(0, notificationBuilder.build()); }
From source file:kr.ds.say.MyFirebaseMessagingService.java
private void sendNotification(String message, Bitmap bitmap) { Intent intent = new Intent(this, IntroActivity.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.channel_message_id); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId) .setPriority(NotificationCompat.PRIORITY_MAX).setSmallIcon(R.mipmap.icon) .setContentTitle(getString(R.string.app_name)).setContentText(message).setAutoCancel(true) .setSound(defaultSoundUri).setContentIntent(pendingIntent); if (bitmap != null) { NotificationCompat.BigPictureStyle style = new NotificationCompat.BigPictureStyle(); style.setBigContentTitle(getString(R.string.app_name)); style.setSummaryText(message);//from w ww . j a v a 2 s. co m style.bigPicture(bitmap); notificationBuilder.setStyle(style); } 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, getString(R.string.channel_message_id), NotificationManager.IMPORTANCE_DEFAULT); channel.setDescription(getString(R.string.channel_message)); notificationManager.createNotificationChannel(channel); } notificationManager.notify(UniqueID.getRandomNumber(1000), notificationBuilder.build()); }