List of usage examples for android.app Notification PRIORITY_MIN
int PRIORITY_MIN
To view the source code for android.app Notification PRIORITY_MIN.
Click Source Link
From source file:com.achep.acdisplay.notifications.NotificationHelper.java
@NonNull public static Notification buildNotification(@NonNull Context context, final int id, @NonNull Object... objects) { final Resources res = context.getResources(); final NotificationCompat.Builder builder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.stat_acdisplay).setColor(App.ACCENT_COLOR).setAutoCancel(true); PendingIntent pi = null;/* w ww .j a v a 2s .co m*/ switch (id) { case App.ID_NOTIFY_TEST: { NotificationCompat.BigTextStyle bts = new NotificationCompat.BigTextStyle() .bigText(res.getString(R.string.notification_test_message_large)); builder.setStyle(bts).setContentTitle(res.getString(R.string.app_name)) .setContentText(res.getString(R.string.notification_test_message)) .setLargeIcon(BitmapFactory.decodeResource(res, R.mipmap.ic_launcher)) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); break; } case App.ID_NOTIFY_BATH: { CharSequence contentText = (CharSequence) objects[0]; Intent contentIntent = (Intent) objects[1]; // Build notification pi = PendingIntent.getActivity(context, id, contentIntent, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentTitle(res.getString(R.string.service_bath)).setContentText(contentText) .setPriority(Notification.PRIORITY_MIN); break; } case App.ID_NOTIFY_INIT: { builder.setSmallIcon(R.drawable.stat_notify).setContentTitle(res.getString(R.string.app_name)) .setContentText(res.getString(R.string.notification_init_text)) .setPriority(Notification.PRIORITY_MIN); break; } case App.ID_NOTIFY_APP_AUTO_DISABLED: { CharSequence summary = (CharSequence) objects[0]; NotificationCompat.BigTextStyle bts = new NotificationCompat.BigTextStyle() .bigText(res.getString(R.string.permissions_auto_disabled)).setSummaryText(summary); builder.setLargeIcon(BitmapFactory.decodeResource(res, R.mipmap.ic_launcher)) .setContentTitle(res.getString(R.string.app_name)) .setContentText(res.getString(R.string.permissions_auto_disabled)) .setPriority(Notification.PRIORITY_HIGH).setStyle(bts); break; } default: throw new IllegalArgumentException(); } if (pi == null) { pi = PendingIntent.getActivity(context, id, new Intent(context, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT); } return builder.setContentIntent(pi).build(); }
From source file:com.paranoid.halo.utils.Notes.java
public static void showNoteNotification(Context context, NotificationManager notificationManager, int id, String note) {//from w w w . jav a 2s. c om Intent intent = new Intent(context, NotesActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); NotificationCompat.Builder ext_builder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_add).setContentIntent(pendingIntent).setContentTitle(note); Notification notif = ext_builder.build(); notif.flags |= Notification.FLAG_ONGOING_EVENT; notif.priority = Notification.PRIORITY_MIN; notif.tickerText = note; notificationManager.notify(id, notif); }
From source file:com.achep.acdisplay.notifications.NotificationListenerJellyBeanMR2.java
@Override public void onListenerBind(@NonNull MediaService service) { mInitialized = false;/*from w ww . j a va 2s.c o m*/ // What is the idea of init notification? // Well the main goal is to access #getActiveNotifications() // what seems to be not possible without dirty and buggy // workarounds. new Handler().postDelayed(new Runnable() { @Override public void run() { MediaService service = MediaService.sService; if (service == null) return; Resources res = service.getResources(); NotificationCompat.Builder builder = new NotificationCompat.Builder(service) .setContentTitle(res.getString(R.string.app_name)) .setContentText(res.getString(R.string.notification_init_text)) .setSmallIcon(R.drawable.stat_notify).setPriority(Notification.PRIORITY_MIN) .setAutoCancel(true).setColor(App.ACCENT_COLOR); String name = Context.NOTIFICATION_SERVICE; NotificationManager nm = (NotificationManager) service.getSystemService(name); nm.notify(App.ID_NOTIFY_INIT, builder.build()); } }, 2000); }
From source file:com.ubergeek42.WeechatAndroid.service.Notificator.java
@AnyThread @Cat/* w w w . ja v a 2 s .co m*/ static void showMain(@NonNull RelayService relay, @NonNull String content) { PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, WeechatActivity.class), PendingIntent.FLAG_CANCEL_CURRENT); boolean authenticated = relay.state.contains(AUTHENTICATED); int icon = authenticated ? R.drawable.ic_connected : R.drawable.ic_disconnected; Builder builder = new Builder(context, NOTIFICATION_CHANNEL_CONNECTION_STATUS); builder.setContentIntent(contentIntent).setSmallIcon(icon) .setContentTitle("Weechat-Android " + BuildConfig.VERSION_NAME).setContentText(content) .setWhen(System.currentTimeMillis()); builder.setPriority(Notification.PRIORITY_MIN); if (P.notificationTicker) builder.setTicker(content); String disconnectText = context.getString(authenticated ? R.string.disconnect : R.string.stop_connecting); builder.addAction(android.R.drawable.ic_menu_close_clear_cancel, disconnectText, PendingIntent.getService( context, 0, new Intent(RelayService.ACTION_STOP, null, context, RelayService.class), 0)); Notification notification = builder.build(); notification.flags |= Notification.FLAG_ONGOING_EVENT; relay.startForeground(NOTIFICATION_MAIN_ID, notification); }
From source file:com.google.android.apps.muzei.NewWallpaperNotificationReceiver.java
public static void maybeShowNewArtworkNotification(Context context, Artwork artwork, BitmapRegionLoader bitmapRegionLoader) { if (artwork == null || artwork.getImageUri() == null || bitmapRegionLoader == null) { return;/* ww w . j av a2 s.c o m*/ } ArtDetailOpenedClosedEvent adoce = EventBus.getDefault().getStickyEvent(ArtDetailOpenedClosedEvent.class); if (adoce != null && adoce.isArtDetailOpened()) { return; } SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); if (!sp.getBoolean(PREF_ENABLED, true)) { return; } String lastSeenImageUri = sp.getString(PREF_LAST_SEEN_NOTIFICATION_IMAGE_URI, null); if (TextUtils.equals(lastSeenImageUri, artwork.getImageUri().toString())) { return; } Rect rect = new Rect(); int width = bitmapRegionLoader.getWidth(); int height = bitmapRegionLoader.getHeight(); if (width > height) { rect.set((width - height) / 2, 0, (width + height) / 2, height); } else { rect.set(0, (height - width) / 2, width, (height + width) / 2); } BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = ImageUtil.calculateSampleSize(height, 256); Bitmap largeIcon = bitmapRegionLoader.decodeRegion(rect, options); NotificationCompat.Builder nb = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_stat_muzei).setPriority(Notification.PRIORITY_MIN).setAutoCancel(true) .setContentTitle(artwork.getTitle()) .setContentText(context.getString(R.string.notification_new_wallpaper)).setLargeIcon(largeIcon) .setContentIntent(PendingIntent.getActivity(context, 0, Intent.makeMainActivity(new ComponentName(context, MuzeiActivity.class)), PendingIntent.FLAG_UPDATE_CURRENT)) .setDeleteIntent(PendingIntent.getBroadcast(context, 0, new Intent(context, NewWallpaperNotificationReceiver.class) .setAction(ACTION_MARK_NOTIFICATION_READ), PendingIntent.FLAG_UPDATE_CURRENT)); NotificationCompat.BigPictureStyle style = new NotificationCompat.BigPictureStyle(nb).bigLargeIcon(null) .setBigContentTitle(artwork.getTitle()).setSummaryText(artwork.getByline()).bigPicture(largeIcon); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(NOTIFICATION_ID, style.build()); // Clear any last-seen notification sp.edit().remove(PREF_LAST_SEEN_NOTIFICATION_IMAGE_URI).apply(); }
From source file:cw.kop.autobackground.files.DownloadThread.java
@Override public void run() { super.run();/* w w w . j a va 2s. c om*/ Looper.prepare(); if (AppSettings.useDownloadNotification()) { PendingIntent pendingStopIntent = PendingIntent.getBroadcast(appContext, 0, new Intent(LiveWallpaperService.STOP_DOWNLOAD), 0); notificationManager = (NotificationManager) appContext.getSystemService(Context.NOTIFICATION_SERVICE); notifyProgress = new Notification.Builder(appContext).setContentTitle("AutoBackground") .setContentText("Downloading images...").setSmallIcon(R.drawable.ic_photo_white_24dp); if (Build.VERSION.SDK_INT >= 16) { notifyProgress.setPriority(Notification.PRIORITY_MIN); notifyProgress.addAction(R.drawable.ic_cancel_white_24dp, "Stop Download", pendingStopIntent); } updateNotification(0); } String downloadCacheDir = AppSettings.getDownloadPath(); File cache = new File(downloadCacheDir); if (!cache.exists() || !cache.isDirectory()) { cache.mkdir(); } List<Integer> indexes = new ArrayList<>(); for (int index = 0; index < AppSettings.getNumberSources(); index++) { Source source = AppSettings.getSource(index); if (!source.getType().equals(AppSettings.FOLDER) && source.isUse()) { indexes.add(index); progressMax += source.getNum(); } } usedLinks = new HashSet<>(); if (AppSettings.checkDuplicates()) { Set<String> rawLinks = AppSettings.getUsedLinks(); for (String link : rawLinks) { if (link.lastIndexOf("Time:") > 0) { link = link.substring(0, link.lastIndexOf("Time:")); } usedLinks.add(link); } } downloadedFiles = new ArrayList<>(); for (int index : indexes) { Source source = AppSettings.getSource(index); if (isInterrupted()) { cancel(); return; } try { if (AppSettings.deleteOldImages()) { FileHandler.deleteBitmaps(appContext, source); } String title = source.getTitle(); File file = new File(downloadCacheDir + "/" + title + " " + AppSettings.getImagePrefix()); if (!file.exists() || !file.isDirectory()) { file.mkdir(); } String sourceType = source.getType(); String sourceData = source.getData(); switch (sourceType) { case AppSettings.WEBSITE: downloadWebsite(sourceData, source); break; case AppSettings.IMGUR_SUBREDDIT: downloadImgurSubreddit(sourceData, source); break; case AppSettings.IMGUR_ALBUM: downloadImgurAlbum(sourceData, source); break; case AppSettings.GOOGLE_ALBUM: downloadPicasa(sourceData, source); break; case AppSettings.TUMBLR_BLOG: downloadTumblrBlog(sourceData, source); break; case AppSettings.TUMBLR_TAG: downloadTumblrTag(sourceData, source); break; case AppSettings.REDDIT_SUBREDDIT: downloadRedditSubreddit(sourceData, source); break; } totalTarget += source.getNum(); updateNotification(totalTarget); } catch (IOException | IllegalArgumentException e) { sendToast("Invalid URL: " + source.getData()); Log.i(TAG, "Invalid URL"); } } finish(); }
From source file:com.farmerbb.taskbar.service.NotificationService.java
@TargetApi(Build.VERSION_CODES.M) @Override//from w w w. j av a 2s .co m public void onCreate() { super.onCreate(); SharedPreferences pref = U.getSharedPreferences(this); if (pref.getBoolean("taskbar_active", false)) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || Settings.canDrawOverlays(this)) { isHidden = U.getSharedPreferences(this).getBoolean("is_hidden", false); String label = getString(isHidden ? R.string.action_show : R.string.action_hide); Intent intent = new Intent(this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); PendingIntent receiverIntent = PendingIntent.getBroadcast(this, 0, new Intent("com.farmerbb.taskbar.SHOW_HIDE_TASKBAR"), PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent receiverIntent2 = PendingIntent.getBroadcast(this, 0, new Intent("com.farmerbb.taskbar.QUIT"), PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(pref.getBoolean("app_drawer_icon", false) ? R.drawable.ic_system : R.drawable.ic_allapps) .setContentIntent(contentIntent).setContentTitle(getString(R.string.taskbar_is_active)) .setContentText(getString(R.string.click_to_open_settings)) .setColor(ContextCompat.getColor(this, R.color.colorPrimary)) .addAction(0, label, receiverIntent) .addAction(0, getString(R.string.action_quit), receiverIntent2) .setPriority(Notification.PRIORITY_MIN).setShowWhen(false).setOngoing(true); startForeground(8675309, mBuilder.build()); LocalBroadcastManager.getInstance(this) .sendBroadcast(new Intent("com.farmerbb.taskbar.UPDATE_SWITCH")); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) TileService.requestListeningState(this, new ComponentName(BuildConfig.APPLICATION_ID, QuickSettingsTileService.class.getName())); if (!isHidden) { registerReceiver(userForegroundReceiver, new IntentFilter(Intent.ACTION_USER_FOREGROUND)); registerReceiver(userBackgroundReceiver, new IntentFilter(Intent.ACTION_USER_BACKGROUND)); } } else { pref.edit().putBoolean("taskbar_active", false).apply(); stopSelf(); } } else stopSelf(); }
From source file:com.mattprecious.smsfix.library.FixService.java
@Override public void onCreate() { super.onCreate(); Log.d(TAG, "FixService starting"); running = true;/*from ww w . java 2s. c o m*/ settings = PreferenceManager.getDefaultSharedPreferences(this); telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); // set up everything we need for the running notification notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); int icon = R.drawable.icon; if (settings.getString("notify_icon", "grey").equals("grey")) { icon = R.drawable.icon_bw; } NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this); notificationBuilder.setSmallIcon(icon); notificationBuilder.setOngoing(true); notificationBuilder.setPriority(Notification.PRIORITY_MIN); notificationBuilder.setContentTitle(getString(R.string.app_name)); notificationBuilder.setContentText(getString(R.string.notify_message)); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, SMSFix.class), 0); notificationBuilder.setContentIntent(contentIntent); notification = notificationBuilder.build(); // shit's broken... throw my own exception so I don't have to read stack traces if (SMS_URI == null) { Log.e(TAG, "SMS URI is null"); throw new RuntimeException("SMS URI is null"); } // MMS URI is null, but this isn't vital... log it. if (MMS_URI == null) { Log.w(TAG, "MMS URI is null"); } else { lastMmsId = SmsMmsDbHelper.getLastMessageId(this, MMS_URI); Log.d(TAG, "lastMmsId initialized to " + lastMmsId); } // get the current last message ID lastSmsId = SmsMmsDbHelper.getLastMessageId(this, SMS_URI); Log.d(TAG, "lastSmsId initialized to " + lastSmsId); try { mmsSmsObserver = new FixServiceObserver(FixServiceObserver.TYPE_MMS_SMS); mmsSmsCursor = SmsMmsDbHelper.getInboxCursor(this, MMS_SMS_URI, null, null); mmsSmsCursor.registerContentObserver(mmsSmsObserver); } catch (NullPointerException e) { smsObserver = new FixServiceObserver(FixServiceObserver.TYPE_SMS); smsCursor = SmsMmsDbHelper.getInboxCursor(this, SMS_URI, null, null); smsCursor.registerContentObserver(smsObserver); if (MMS_URI != null && settings.getBoolean("mms", true)) { mmsObserver = new FixServiceObserver(FixServiceObserver.TYPE_MMS); mmsCursor = SmsMmsDbHelper.getInboxCursor(this, MMS_URI, null, null); mmsCursor.registerContentObserver(mmsObserver); } } setupForegroundVars(); Log.d(TAG, "FixService initialization complete. Now monitoring SMS messages"); }
From source file:com.github.chenxiaolong.dualbootpatcher.switcher.SwitcherService.java
private void setForegroundNotification() { Intent startupIntent = new Intent(this, MainActivity.class); startupIntent.setAction(Intent.ACTION_MAIN); startupIntent.addCategory(Intent.CATEGORY_LAUNCHER); PendingIntent startupPendingIntent = PendingIntent.getActivity(this, 0, startupIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher).setContentIntent(startupPendingIntent) .setContentTitle(getString(R.string.switcher_service_background_service)) .setPriority(Notification.PRIORITY_MIN); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.setCategory(Notification.CATEGORY_SERVICE); }/*from w w w . jav a 2 s. co m*/ startForeground(NOTIFICATION_ID, builder.build()); }
From source file:net.networksaremadeofstring.rhybudd.Notifications.java
public static void SendGCMNotification(ZenossEvent Event, Context context) { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); Time now = new Time(); now.setToNow();//w w w.j a va 2 s . c om //We don't need to overwhelm the user with their notification sound / vibrator if ((now.toMillis(true) - PreferenceManager.getDefaultSharedPreferences(context).getLong("lastCheck", now.toMillis(true))) < 3000) { //Log.e("SendGCMNotification", "Not publishing a notification due to stampede control"); return; } Intent notificationIntent = new Intent(context, ViewZenossEventsListActivity.class); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); notificationIntent.putExtra("forceRefresh", true); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); Uri soundURI = null; try { if (settings.getBoolean("notificationSound", true)) { if (settings.getString("notificationSoundChoice", "").equals("")) { soundURI = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); } else { try { soundURI = Uri.parse(settings.getString("notificationSoundChoice", "")); } catch (Exception e) { soundURI = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); } } } else { soundURI = null; } } catch (Exception e) { } String notifTitle = "New Events Received"; int notifPriority = Notification.PRIORITY_DEFAULT; //int AlertType = NOTIFICATION_GCM_GENERIC; try { if (Event.getSeverity().equals("5")) { notifTitle = context.getString(R.string.CriticalNotificationTitle); notifPriority = Notification.PRIORITY_MAX; //AlertType = NOTIFICATION_GCM_CRITICAL; } else if (Event.getSeverity().equals("4")) { notifTitle = context.getString(R.string.ErrorNotificationTitle); notifPriority = Notification.PRIORITY_HIGH; //AlertType = NOTIFICATION_GCM_ERROR; } else if (Event.getSeverity().equals("3")) { notifTitle = context.getString(R.string.WarnNotificationTitle); notifPriority = Notification.PRIORITY_DEFAULT; //AlertType = NOTIFICATION_GCM_WARNING; } else if (Event.getSeverity().equals("2")) { notifTitle = context.getString(R.string.InfoNotificationTitle); notifPriority = Notification.PRIORITY_LOW; //AlertType = NOTIFICATION_GCM_INFO; } else if (Event.getSeverity().equals("1")) { notifTitle = context.getString(R.string.DebugNotificationTitle); notifPriority = Notification.PRIORITY_MIN; //AlertType = NOTIFICATION_GCM_DEBUG; } } catch (Exception e) { } long[] vibrate = { 0, 100, 200, 300 }; try { AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); //Log.e("audio.getRingerMode()",Integer.toString(audio.getRingerMode())); switch (audio.getRingerMode()) { case AudioManager.RINGER_MODE_SILENT: //Do nothing to fix GitHub issue #13 //Log.e("AudioManager","Doing nothing because we are silent"); vibrate = new long[] { 0, 0 }; break; } } catch (Exception e) { e.printStackTrace(); } Intent broadcastMassAck = new Intent(); broadcastMassAck.setAction(MassAcknowledgeReceiver.BROADCAST_ACTION); PendingIntent pBroadcastMassAck = PendingIntent.getBroadcast(context, 0, broadcastMassAck, 0); if (Build.VERSION.SDK_INT >= 16) { Notification noti = new Notification.BigTextStyle(new Notification.Builder(context) .setContentTitle(notifTitle).setPriority(notifPriority).setAutoCancel(true).setSound(soundURI) .setVibrate(vibrate).setContentText(Event.getDevice()).setContentIntent(contentIntent) .addAction(R.drawable.ic_action_resolve_all, "Acknowledge all Events", pBroadcastMassAck) .setSmallIcon(R.drawable.ic_stat_alert)).bigText( Event.getSummary() + "\r\n" + Event.getComponentText() + "\r\n" + Event.geteventClass()) .build(); if (settings.getBoolean("notificationSoundInsistent", false)) noti.flags |= Notification.FLAG_INSISTENT; noti.tickerText = notifTitle; NotificationManager mNM = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); mNM.notify(NOTIFICATION_GCM_GENERIC, noti); } else { NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_stat_alert).setContentTitle(notifTitle) .setContentText(Event.getDevice() + ": " + Event.getSummary()).setContentIntent(contentIntent) .setSound(soundURI).setVibrate(vibrate) .addAction(R.drawable.ic_action_resolve_all, "Acknowledge all Events", pBroadcastMassAck) .setAutoCancel(true).setPriority(notifPriority); NotificationManager mNM = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); mNM.notify(NOTIFICATION_GCM_GENERIC, mBuilder.build()); } }