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:cw.kop.autobackground.LiveWallpaperService.java
@SuppressLint("NewApi") private void startNotification(boolean useNotification) { if (useNotification) { normalView = new RemoteViews(getPackageName(), R.layout.notification_layout); normalView.setInt(R.id.notification_container, "setBackgroundColor", AppSettings.getNotificationColor()); normalView.setImageViewResource(R.id.notification_icon, R.drawable.app_icon); normalView.setTextViewText(R.id.notification_title, AppSettings.getNotificationTitle()); normalView.setInt(R.id.notification_title, "setTextColor", AppSettings.getNotificationTitleColor()); normalView.setTextViewText(R.id.notification_summary, AppSettings.getNotificationSummary()); normalView.setInt(R.id.notification_summary, "setTextColor", AppSettings.getNotificationSummaryColor()); Drawable coloredImageOne = LiveWallpaperService.this.getResources() .getDrawable(AppSettings.getNotificationOptionDrawable(0)); Drawable coloredImageTwo = LiveWallpaperService.this.getResources() .getDrawable(AppSettings.getNotificationOptionDrawable(1)); Drawable coloredImageThree = LiveWallpaperService.this.getResources() .getDrawable(AppSettings.getNotificationOptionDrawable(2)); coloredImageOne.mutate().setColorFilter(AppSettings.getNotificationOptionColor(0), PorterDuff.Mode.MULTIPLY); coloredImageTwo.mutate().setColorFilter(AppSettings.getNotificationOptionColor(1), PorterDuff.Mode.MULTIPLY); coloredImageThree.mutate().setColorFilter(AppSettings.getNotificationOptionColor(2), PorterDuff.Mode.MULTIPLY); Bitmap mutableBitmapOne = Bitmap.createBitmap(coloredImageOne.getIntrinsicWidth(), coloredImageOne.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvasOne = new Canvas(mutableBitmapOne); coloredImageOne.setBounds(0, 0, coloredImageOne.getIntrinsicWidth(), coloredImageOne.getIntrinsicHeight()); coloredImageOne.draw(canvasOne); Bitmap mutableBitmapTwo = Bitmap.createBitmap(coloredImageTwo.getIntrinsicWidth(), coloredImageTwo.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvasTwo = new Canvas(mutableBitmapTwo); coloredImageTwo.setBounds(0, 0, coloredImageTwo.getIntrinsicWidth(), coloredImageTwo.getIntrinsicHeight()); coloredImageTwo.draw(canvasTwo); Bitmap mutableBitmapThree = Bitmap.createBitmap(coloredImageThree.getIntrinsicWidth(), coloredImageThree.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvasThree = new Canvas(mutableBitmapThree); coloredImageThree.setBounds(0, 0, coloredImageThree.getIntrinsicWidth(), coloredImageThree.getIntrinsicHeight()); coloredImageThree.draw(canvasThree); if (AppSettings.useNotificationGame()) { if (setupGameTiles()) { bigView = new RemoteViews(getPackageName(), R.layout.notification_game); tileIds = new int[] { R.id.notification_game_tile_0, R.id.notification_game_tile_1, R.id.notification_game_tile_2, R.id.notification_game_tile_3, R.id.notification_game_tile_4, R.id.notification_game_tile_5, R.id.notification_game_tile_6, R.id.notification_game_tile_7, R.id.notification_game_tile_8, R.id.notification_game_tile_9 }; bigView.setOnClickPendingIntent(tileIds[0], pendingTile0); bigView.setOnClickPendingIntent(tileIds[1], pendingTile1); bigView.setOnClickPendingIntent(tileIds[2], pendingTile2); bigView.setOnClickPendingIntent(tileIds[3], pendingTile3); bigView.setOnClickPendingIntent(tileIds[4], pendingTile4); bigView.setOnClickPendingIntent(tileIds[5], pendingTile5); bigView.setOnClickPendingIntent(tileIds[6], pendingTile6); bigView.setOnClickPendingIntent(tileIds[7], pendingTile7); bigView.setOnClickPendingIntent(tileIds[8], pendingTile8); bigView.setOnClickPendingIntent(tileIds[9], pendingTile9); } else { bigView = new RemoteViews(getPackageName(), R.layout.notification_big_layout); closeNotificationDrawer(LiveWallpaperService.this); Toast.makeText(LiveWallpaperService.this, "Not enough images to create game", Toast.LENGTH_LONG) .show();//from w ww .ja va2s. c o m AppSettings.setUseNotificationGame(false); } } else { bigView = new RemoteViews(getPackageName(), R.layout.notification_big_layout); } bigView.setInt(R.id.notification_big_container, "setBackgroundColor", AppSettings.getNotificationColor()); bigView.setImageViewResource(R.id.notification_big_icon, R.drawable.app_icon); bigView.setTextViewText(R.id.notification_big_title, AppSettings.getNotificationTitle()); bigView.setInt(R.id.notification_big_title, "setTextColor", AppSettings.getNotificationTitleColor()); bigView.setTextViewText(R.id.notification_big_summary, AppSettings.getNotificationSummary()); bigView.setInt(R.id.notification_big_summary, "setTextColor", AppSettings.getNotificationSummaryColor()); bigView.setImageViewBitmap(R.id.notification_button_one_image, mutableBitmapOne); bigView.setImageViewBitmap(R.id.notification_button_two_image, mutableBitmapTwo); bigView.setImageViewBitmap(R.id.notification_button_three_image, mutableBitmapThree); bigView.setTextViewText(R.id.notification_button_one_text, AppSettings.getNotificationOptionTitle(0)); bigView.setInt(R.id.notification_button_one_text, "setTextColor", AppSettings.getNotificationOptionColor(0)); bigView.setTextViewText(R.id.notification_button_two_text, AppSettings.getNotificationOptionTitle(1)); bigView.setInt(R.id.notification_button_two_text, "setTextColor", AppSettings.getNotificationOptionColor(1)); bigView.setTextViewText(R.id.notification_button_three_text, AppSettings.getNotificationOptionTitle(2)); bigView.setInt(R.id.notification_button_three_text, "setTextColor", AppSettings.getNotificationOptionColor(2)); if (getIntentForNotification(AppSettings.getNotificationIconAction()) != null) { normalView.setOnClickPendingIntent(R.id.notification_icon, getIntentForNotification(AppSettings.getNotificationIconAction())); bigView.setOnClickPendingIntent(R.id.notification_big_icon, getIntentForNotification(AppSettings.getNotificationIconAction())); } else { normalView.setOnClickPendingIntent(R.id.notification_icon, pendingAppIntent); bigView.setOnClickPendingIntent(R.id.notification_big_icon, pendingAppIntent); } notificationBuilder = new Notification.Builder(this).setContent(normalView) .setSmallIcon(R.drawable.notification_icon).setOngoing(true); if (Build.VERSION.SDK_INT >= 16) { if (AppSettings.useNotificationGame()) { notificationBuilder.setPriority(Notification.PRIORITY_MAX); } else { notificationBuilder.setPriority(Notification.PRIORITY_MIN); } if (getIntentForNotification(AppSettings.getNotificationOptionTitle(0)) != null) { bigView.setOnClickPendingIntent(R.id.notification_button_one, getIntentForNotification(AppSettings.getNotificationOptionTitle(0))); } if (getIntentForNotification(AppSettings.getNotificationOptionTitle(1)) != null) { bigView.setOnClickPendingIntent(R.id.notification_button_two, getIntentForNotification(AppSettings.getNotificationOptionTitle(1))); } if (getIntentForNotification(AppSettings.getNotificationOptionTitle(2)) != null) { bigView.setOnClickPendingIntent(R.id.notification_button_three, getIntentForNotification(AppSettings.getNotificationOptionTitle(2))); } } else { notificationBuilder.setContentTitle(AppSettings.getNotificationTitle()); notificationBuilder.setContentText(AppSettings.getNotificationSummary()); notificationBuilder.addAction(AppSettings.getNotificationOptionDrawable(0), AppSettings.getNotificationOptionTitle(0), getIntentForNotification(AppSettings.getNotificationOptionTitle(0))); notificationBuilder.addAction(AppSettings.getNotificationOptionDrawable(1), AppSettings.getNotificationOptionTitle(1), getIntentForNotification(AppSettings.getNotificationOptionTitle(1))); notificationBuilder.addAction(AppSettings.getNotificationOptionDrawable(2), AppSettings.getNotificationOptionTitle(2), getIntentForNotification(AppSettings.getNotificationOptionTitle(2))); } pushNotification(); if (FileHandler.getCurrentBitmapFile() != null) { notifyChangeImage(); } } else { notificationManager.cancel(NOTIFICATION_ID); } }
From source file:saphion.services.ForegroundService.java
@SuppressWarnings("deprecation") void handleCommand() { mPref = getSharedPreferences(PREF_NAME, MODE_MULTI_PROCESS); // if (ACTION_FOREGROUND.equals(intent.getAction())) { // In this sample, we'll use the same text for the ticker and the // expanded notification // CharSequence text = getText(R.string.foreground_service_started); // Set the icon, scrolling text and timestamp try {//from w w w . ja va 2 s. co m handleTrigger(level); } catch (Exception ex) { Log.d(ex.toString()); } RemoteViews rvNoti = new RemoteViews(getPackageName(), R.layout.smallnoti); NotificationCompat.Builder builder;/* * = new NotificationCompat.Builder( * getBaseContext * ()).setContent(rvNoti); * builder.build(); */ Notification notification = new Notification(getId(level), null, 0); // The PendingIntent to launch our activity if the user selects this // notification PendingIntent contentIntent = null; Intent localIntent; switch (mPref.getInt(PreferenceHelper.NOTI_ONCLICK, 2)) { case 0: contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, TabNavigation.class), 0); break; case 1: localIntent = new Intent(); localIntent.setFlags(346030080); localIntent.setAction("android.intent.action.POWER_USAGE_SUMMARY"); contentIntent = PendingIntent.getActivity(this, 0, localIntent, 0); break; case 2: contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, Controller.class), 0); break; case 3: contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, ToggleDialog.class), 0); break; } String prevTime = mPref.getString(PreferenceHelper.PREV_BAT_TIME, TimeFuncs.getCurrentTimeStamp()); long diff = TimeFuncs.newDiff(TimeFuncs.GetItemDate(prevTime), TimeFuncs.GetItemDate(TimeFuncs.getCurrentTimeStamp())); Log.d("New diff " + diff); // TODO Log.d("Previous Date: " + TimeFuncs.GetItemDate(prevTime)); Log.d("Current Date: " + TimeFuncs.GetItemDate(TimeFuncs.getCurrentTimeStamp())); // Log.d( "Previous Timestamp " + level + ""); // Log.d( "Current Timestamp " + level + ""); String subtext; Log.d("Current Level " + level + ""); Log.d("Previous Level " + mPref.getInt(PreferenceHelper.PREV_BAT_LEVEL, level) + ""); if (level < mPref.getInt(PreferenceHelper.PREV_BAT_LEVEL, level)) { diff = (long) (mPref.getLong(PreferenceHelper.BAT_DISCHARGE, diff)); reqTime = diff * level; subtext = "Empty in " + TimeFuncs.convtohournminnday(reqTime); // mPref // .edit().putLong(PreferenceHelper.BAT_DISCHARGE, diff) // .commit(); Log.d("Discharging with " + diff); } else { if (level > mPref.getInt(PreferenceHelper.PREV_BAT_LEVEL, level)) { if (level != 100 && TimeFuncs.convtohournminnday(diff * (100 - level)).equalsIgnoreCase("0 Minute(s)")) { reqTime = (long) (81 * (100 - level)); subtext = "Full Charge in " + TimeFuncs.convtohournminnday(reqTime); } else { reqTime = diff * (100 - level); subtext = "Full Charge in " + TimeFuncs.convtohournminnday(reqTime); mPref.edit().putLong(PreferenceHelper.BAT_CHARGE, diff).commit(); } Log.d("Charging with " + diff); } else { if (isconnected) { reqTime = (long) (mPref.getLong(PreferenceHelper.BAT_CHARGE, 81) * (100 - level)); subtext = "Full Charge in " + TimeFuncs.convtohournminnday(reqTime); Log.d("Estimating Charging"); // mPref // .edit().putLong("batcharge", diff).commit(); Log.d("EST Charging with " + diff); } else { reqTime = (long) (mPref.getLong(PreferenceHelper.BAT_DISCHARGE, 792) * (level)); subtext = "Empty in " + TimeFuncs.convtohournminnday(reqTime); Log.d("Estimating Discharging with: " + (long) (mPref.getLong(PreferenceHelper.BAT_DISCHARGE, 792))); } } } if (level == 100 && isconnected) { subtext = "Fully Charged"; reqTime = 0; } String mainText = mPref.getString(PreferenceHelper.LAST_CHARGED, TimeFuncs.getCurrentTimeStamp()); if (isconnected) { if (mPref.getBoolean("plugged?", true)) mPref.edit().putString(PreferenceHelper.LAST_CHARGED, TimeFuncs.getCurrentTimeStamp()).commit(); String time = TimeFuncs.convtohournminnday(TimeFuncs.newDiff(TimeFuncs.GetItemDate(mainText), TimeFuncs.GetItemDate(TimeFuncs.getCurrentTimeStamp()))); if (!time.equals("0 Minute(s)")) mainText = "Plugged " + time + " ago"; else mainText = "Plugged " + "right now"; mPref.edit().putBoolean("plugged?", false).commit(); } else { if (!mPref.getBoolean("plugged?", true)) { mPref.edit().putBoolean("plugged?", true).commit(); mPref.edit().putString(PreferenceHelper.LAST_CHARGED, TimeFuncs.getCurrentTimeStamp()).commit(); } mainText = mPref.getString(PreferenceHelper.LAST_CHARGED, TimeFuncs.getCurrentTimeStamp()); String time = TimeFuncs.convtohournminnday(TimeFuncs.newDiff(TimeFuncs.GetItemDate(mainText), TimeFuncs.GetItemDate(TimeFuncs.getCurrentTimeStamp()))); if (!time.equals("0 Minute(s)")) mainText = "Unplugged " + time + " ago"; else mainText = "Unplugged " + "right now"; } String tempsubtext = subtext; subtext = setNotText(subtext, mainText, mPref.getInt(PreferenceHelper.NOTI_SUBTEXT, 3)); mainText = setNotText(tempsubtext, mainText, mPref.getInt(PreferenceHelper.NOTI_MAINTEXT, 6)); // Set the info for the views that show in the notification panel int srcId = getId(level); builder = new NotificationCompat.Builder(this).setSmallIcon(srcId).setAutoCancel(false).setOngoing(true) .setContentTitle(mainText).setContentText(subtext).setTicker(null).setWhen(0); // modification rvNoti.setImageViewResource(R.id.notification_icon, srcId); rvNoti.setTextViewText(R.id.tvNotiPrevmainText, mainText); rvNoti.setTextViewText(R.id.tvNotiPrevsubText, subtext); rvLargeNoti = new RemoteViews(getPackageName(), R.layout.largenoti); /*if (Build.VERSION.SDK_INT != 20)*/ builder.setContent(rvNoti); // Intent notificationIntent = new Intent(this, // ForegroundService.class); // contentIntent = PendingIntent.getActivity(this, 0, // notificationIntent, // PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(contentIntent); switch (mPref.getInt(PreferenceHelper.NOTI_PRIORITY, 2)) { case 0: builder.setPriority(NotificationCompat.PRIORITY_HIGH); break; case 1: builder.setPriority(NotificationCompat.PRIORITY_MIN); break; case 2: builder.setPriority(NotificationCompat.PRIORITY_DEFAULT); break; case 3: builder.setPriority(NotificationCompat.PRIORITY_LOW); break; case 4: builder.setPriority(NotificationCompat.PRIORITY_MAX); break; } // builder. notification = builder.build(); /*if (Build.VERSION.SDK_INT != 20)*/ notification.contentView = rvNoti; /*if (Build.VERSION.SDK_INT == 20) { * builder = new * Notification.Builder(this).setContentTitle(mainText) * .setContentText(subtext).setTicker(null).setWhen(0) * .setOngoing(true).setSmallIcon(srcId) * .setContentIntent(pendingIntent).addAction(call) * .addAction(cancel).setAutoCancel(false); setKitkatActions(builder); notification = builder.build(); } else*/ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { rvLargeNoti.setImageViewResource(R.id.notification_icon_large, srcId); if (mPref.getBoolean(PreferenceHelper.SHOW_CHART, true)) { vals = new ArrayList<Double>(); dates = new ArrayList<Double>(); vals = SerialPreference.retPrefs(getBaseContext(), PreferenceHelper.BAT_VALS); dates = SerialPreference.retPrefs(getBaseContext(), PreferenceHelper.BAT_TIME); GraphicalView mChartView = ChartFactory.getTimeChartView(getBaseContext(), getDateDataset(), getRenderer(), "EEE, h:mm a"); Bitmap outBitmap = Bitmap.createScaledBitmap(loadBitmapFromView(mChartView), getResources().getDisplayMetrics().widthPixels, Functions.ReturnHeight(140, getBaseContext()), true); rvLargeNoti.setImageViewBitmap(R.id.ivchart_large, outBitmap); rvLargeNoti.setViewVisibility(R.id.ivchart_large, View.VISIBLE); } else { rvLargeNoti.setViewVisibility(R.id.ivchart_large, View.GONE); } rvLargeNoti.setTextViewText(R.id.tvNotiPrevmainText_large, mainText); rvLargeNoti.setTextViewText(R.id.tvNotiPrevsubText_large, subtext); setResourceImages(rvLargeNoti); setIntents(rvLargeNoti); notification.bigContentView = rvLargeNoti; } if (mPref.getBoolean(PreferenceHelper.NOTIFICATION_ENABLE, true)) { /* * startForegroundCompat(R.string.foreground_service_started, * notification); */ startForeground(notiID, notification); } else { notification.icon = R.drawable.abc_ab_bottom_transparent_dark_holo; try { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) notification.priority = Notification.PRIORITY_MIN; } catch (Exception ex) { } startForeground(notiID, notification); startService(new Intent(ForegroundService.this, FakeService.class)); } /* * if(DISPLAY != null){ if(DISPLAY){ startForeground(notiID, * notification); Log.Toast(getBaseContext(), "displaying notification", * Toast.LENGTH_LONG); }else{ Log.Toast(getBaseContext(), * "not gonna display", Toast.LENGTH_LONG); * //startForegroundCompat(R.string.foreground_service_started, null); * notification.icon = R.drawable.abc_ab_bottom_transparent_dark_holo; * notification.priority = Notification.PRIORITY_MIN; * startForeground(notiID, notification); startService(new * Intent(ForegroundService.this, FakeService.class)); } } */ if (level != mPref.getInt(PreferenceHelper.PREV_BAT_LEVEL, level)) mPref.edit().putString(PreferenceHelper.PREV_BAT_TIME, TimeFuncs.getCurrentTimeStamp()).commit(); mPref.edit().putInt(PreferenceHelper.PREV_BAT_LEVEL, level).commit(); }
From source file:eu.faircode.adblocker.ServiceSinkhole.java
private Notification getEnforcingNotification(int allowed, int blocked, int hosts) { Intent main = new Intent(this, ActivityMain.class); PendingIntent pi = PendingIntent.getActivity(this, 0, main, PendingIntent.FLAG_UPDATE_CURRENT); TypedValue tv = new TypedValue(); getTheme().resolveAttribute(R.attr.colorPrimary, tv, true); NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_security_white_24dp).setContentTitle(getString(R.string.app_name)) .setContentText(getString(R.string.msg_started)).setContentIntent(pi).setColor(tv.data) .setOngoing(true).setAutoCancel(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.setCategory(Notification.CATEGORY_STATUS).setVisibility(Notification.VISIBILITY_SECRET) .setPriority(Notification.PRIORITY_MIN); }/* ww w .j a v a 2 s .co m*/ if (allowed > 0 || blocked > 0 || hosts > 0) { NotificationCompat.BigTextStyle notification = new NotificationCompat.BigTextStyle(builder); notification.bigText(getString(R.string.msg_started)); if (Util.isPlayStoreInstall(this)) notification.setSummaryText(getString(R.string.msg_packages, allowed, blocked)); else notification.setSummaryText(getString(R.string.msg_hosts, allowed, blocked, hosts)); return notification.build(); } else return builder.build(); }
From source file:eu.faircode.adblocker.ServiceSinkhole.java
private Notification getWaitingNotification() { Intent main = new Intent(this, ActivityMain.class); PendingIntent pi = PendingIntent.getActivity(this, 0, main, PendingIntent.FLAG_UPDATE_CURRENT); TypedValue tv = new TypedValue(); getTheme().resolveAttribute(R.attr.colorPrimary, tv, true); NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_security_white_24dp).setContentTitle(getString(R.string.app_name)) .setContentText(getString(R.string.msg_waiting)).setContentIntent(pi).setColor(tv.data) .setOngoing(true).setAutoCancel(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.setCategory(Notification.CATEGORY_STATUS).setVisibility(Notification.VISIBILITY_SECRET) .setPriority(Notification.PRIORITY_MIN); }/*from ww w. j av a2 s . c om*/ return builder.build(); }
From source file:android_network.hetnet.vpn_service.ServiceSinkhole.java
private Notification getEnforcingNotification(int allowed, int blocked, int hosts) { Intent main = new Intent(this, MainActivity.class); PendingIntent pi = PendingIntent.getActivity(this, 0, main, PendingIntent.FLAG_UPDATE_CURRENT); TypedValue tv = new TypedValue(); getTheme().resolveAttribute(R.attr.colorPrimary, tv, true); NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_security_white_24dp).setContentIntent(pi).setColor(tv.data) .setOngoing(true).setAutoCancel(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) builder.setContentTitle(getString(R.string.msg_started)); else/* w w w . j a v a 2 s .com*/ builder.setContentTitle(getString(R.string.app_name)).setContentText(getString(R.string.msg_started)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.setCategory(Notification.CATEGORY_STATUS).setVisibility(Notification.VISIBILITY_SECRET) .setPriority(Notification.PRIORITY_MIN); } if (allowed > 0 || blocked > 0 || hosts > 0) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { if (Util.isPlayStoreInstall(this)) builder.setContentText(getString(R.string.msg_packages, allowed, blocked)); else builder.setContentText(getString(R.string.msg_hosts, allowed, blocked, hosts)); return builder.build(); } else { NotificationCompat.BigTextStyle notification = new NotificationCompat.BigTextStyle(builder); notification.bigText(getString(R.string.msg_started)); if (Util.isPlayStoreInstall(this)) notification.setSummaryText(getString(R.string.msg_packages, allowed, blocked)); else notification.setSummaryText(getString(R.string.msg_hosts, allowed, blocked, hosts)); return notification.build(); } } else return builder.build(); }
From source file:android_network.hetnet.vpn_service.ServiceSinkhole.java
private Notification getWaitingNotification() { Intent main = new Intent(this, MainActivity.class); PendingIntent pi = PendingIntent.getActivity(this, 0, main, PendingIntent.FLAG_UPDATE_CURRENT); TypedValue tv = new TypedValue(); getTheme().resolveAttribute(R.attr.colorPrimary, tv, true); NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_security_white_24dp).setContentIntent(pi).setColor(tv.data) .setOngoing(true).setAutoCancel(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) builder.setContentTitle(getString(R.string.msg_waiting)); else//from w w w . j a v a 2 s . c o m builder.setContentTitle(getString(R.string.app_name)).setContentText(getString(R.string.msg_waiting)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.setCategory(Notification.CATEGORY_STATUS).setVisibility(Notification.VISIBILITY_SECRET) .setPriority(Notification.PRIORITY_MIN); } return builder.build(); }
From source file:eu.faircode.netguard.ServiceSinkhole.java
private Notification getEnforcingNotification(int allowed, int blocked, int hosts) { Intent main = new Intent(this, ActivityMain.class); PendingIntent pi = PendingIntent.getActivity(this, 0, main, PendingIntent.FLAG_UPDATE_CURRENT); TypedValue tv = new TypedValue(); getTheme().resolveAttribute(R.attr.colorPrimary, tv, true); NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(isLockedDown(last_metered) ? R.drawable.ic_lock_outline_white_24dp : R.drawable.ic_security_white_24dp) .setContentIntent(pi).setColor(tv.data).setOngoing(true).setAutoCancel(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) builder.setContentTitle(getString(R.string.msg_started)); else/*from w w w .j av a 2 s . c om*/ builder.setContentTitle(getString(R.string.app_name)).setContentText(getString(R.string.msg_started)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.setCategory(Notification.CATEGORY_STATUS).setVisibility(Notification.VISIBILITY_SECRET) .setPriority(Notification.PRIORITY_MIN); } if (allowed > 0 || blocked > 0 || hosts > 0) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { if (Util.isPlayStoreInstall(this)) builder.setContentText(getString(R.string.msg_packages, allowed, blocked)); else builder.setContentText(getString(R.string.msg_hosts, allowed, blocked, hosts)); return builder.build(); } else { NotificationCompat.BigTextStyle notification = new NotificationCompat.BigTextStyle(builder); notification.bigText(getString(R.string.msg_started)); if (Util.isPlayStoreInstall(this)) notification.setSummaryText(getString(R.string.msg_packages, allowed, blocked)); else notification.setSummaryText(getString(R.string.msg_hosts, allowed, blocked, hosts)); return notification.build(); } } else return builder.build(); }
From source file:eu.faircode.netguard.ServiceSinkhole.java
private Notification getWaitingNotification() { Intent main = new Intent(this, ActivityMain.class); PendingIntent pi = PendingIntent.getActivity(this, 0, main, PendingIntent.FLAG_UPDATE_CURRENT); TypedValue tv = new TypedValue(); getTheme().resolveAttribute(R.attr.colorPrimary, tv, true); NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_security_white_24dp).setContentIntent(pi).setColor(tv.data) .setOngoing(true).setAutoCancel(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) builder.setContentTitle(getString(R.string.msg_waiting)); else// www . ja va 2 s . c om builder.setContentTitle(getString(R.string.app_name)).setContentText(getString(R.string.msg_waiting)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.setCategory(Notification.CATEGORY_STATUS).setVisibility(Notification.VISIBILITY_SECRET) .setPriority(Notification.PRIORITY_MIN); } return builder.build(); }