Refine search
static Notification buildNotification(Context ctxt) { NotificationCompat.Builder b=new NotificationCompat.Builder(ctxt) .setOngoing(true) .setContentTitle(ctxt.getString(R.string.notif_title)) .setContentText(ctxt.getString(R.string.notif_text)) .setSmallIcon(android.R.drawable.stat_sys_warning); return(b.build()); }
public void raiseContent(View view) { Notification n=new NotificationCompat.Builder(MainActivity.this, CHANNEL_CONTENT) .setContentTitle(getString(R.string.notif_content_title)) .setContentText(getString(R.string.notify_content_text)) .setSmallIcon(android.R.drawable.stat_sys_warning) .build(); mgr.notify(NOTIF_ID_CONTENT, n); }
private Notification buildForegroundNotification(String filename) { NotificationCompat.Builder b= new NotificationCompat.Builder(this, CHANNEL_WHATEVER); b.setOngoing(true) .setContentTitle(getString(R.string.downloading)) .setContentText(filename) .setSmallIcon(android.R.drawable.stat_sys_download); return(b.build()); } }
.setAutoCancel(true) .setLargeIcon(icDownloadDone) .setSmallIcon(android.R.drawable.stat_sys_download_done) .setDeleteIntent(makePendingIntent(ACTION_RESET_DOWNLOAD_FINISHED)) .setContentIntent(makePendingIntent(ACTION_OPEN_DOWNLOADS_FINISHED)); notificationManager.notify(DOWNLOADS_NOTIFICATION_ID, downloadDoneNotification.build()); downloadDoneCount++;
.setSmallIcon(R.drawable.ic_launcher) .setContentTitle("Title") .setContentText("Notification text") .setContentIntent(resultPendingIntent); Notification notification = builder.build();
.setSmallIcon(R.mipmap.ic_launcher) .setTicker(getString(R.string.app_name)); mgr.notify(NOTIFY_ID, b.build()); startForeground(NOTIFY_ID, b.build()); isForeground=true;
b.setContentTitle(getString(R.string.download_complete)) .setContentText(getString(R.string.fun)) .setSmallIcon(android.R.drawable.stat_sys_download_done); b.setContentTitle(getString(R.string.exception)) .setContentText(e.getMessage()) .setSmallIcon(android.R.drawable.stat_notify_error); mgr.notify(NOTIFY_ID, b.build());
.setSmallIcon(R.drawable.ic_notification) .setContentIntent(clickIntent); builder.setShowWhen(false); return builder.build();
public void showFetchingMailNotification(Account account, Folder folder) { String accountName = account.getDescription(); String folderServerId = folder.getServerId(); String folderName = folder.getName(); String tickerText = resourceProvider.checkingMailTicker(accountName, folderName); String title = resourceProvider.checkingMailTitle(); //TODO: Use format string from resources String text = accountName + resourceProvider.checkingMailSeparator() + folderName; int notificationId = NotificationIds.getFetchingMailNotificationId(account); PendingIntent showMessageListPendingIntent = actionBuilder.createViewFolderPendingIntent( account, folderServerId, notificationId); NotificationCompat.Builder builder = notificationHelper.createNotificationBuilder(account, NotificationChannelManager.ChannelType.MISCELLANEOUS) .setSmallIcon(resourceProvider.getIconCheckingMail()) .setWhen(System.currentTimeMillis()) .setOngoing(true) .setTicker(tickerText) .setContentTitle(title) .setContentText(text) .setContentIntent(showMessageListPendingIntent) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_SERVICE); if (NOTIFICATION_LED_WHILE_SYNCING) { notificationHelper.configureNotification(builder, null, null, account.getNotificationSetting().getLedColor(), NOTIFICATION_LED_BLINK_FAST, true); } getNotificationManager().notify(notificationId, builder.build()); }
@RequiresApi(21) private void sendNotification(Context context, String message, String detail) { initializeWithContext(context); if(this.mNotificationsEnabled) { NotificationCompat.Builder builder = (new NotificationCompat.Builder(context, "err")) .setContentTitle("BluetoothMedic: " + message) .setSmallIcon(mNotificationIcon) .setVibrate(new long[]{200L, 100L, 200L}).setContentText(detail); TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addNextIntent(new Intent("NoOperation")); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent( 0, PendingIntent.FLAG_UPDATE_CURRENT ); builder.setContentIntent(resultPendingIntent); NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); if (notificationManager != null) { notificationManager.notify(1, builder.build()); } } }
/** * Method to compare the current and latest available app version. * If a newer version is available, we show the update notification. * @param versionName * @param apkLocationUrl */ private void compareAppVersionAndShowNotification(String versionName, String apkLocationUrl, String versionCode) { int NOTIFICATION_ID = 2000; if (BuildConfig.VERSION_CODE < Integer.valueOf(versionCode)) { // A pending intent to open the apk location url in the browser. Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(apkLocationUrl)); PendingIntent pendingIntent = PendingIntent.getActivity(app, 0, intent, 0); NotificationCompat.Builder notificationBuilder = new NotificationCompat .Builder(app, app.getString(R.string.app_update_notification_channel_id)) .setSmallIcon(R.drawable.ic_newpipe_update) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setContentIntent(pendingIntent) .setAutoCancel(true) .setContentTitle(app.getString(R.string.app_update_notification_content_title)) .setContentText(app.getString(R.string.app_update_notification_content_text) + " " + versionName); NotificationManagerCompat notificationManager = NotificationManagerCompat.from(app); notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build()); } }
.setContentTitle(getString(R.string.notif_title)) .setContentText(Integer.toHexString(random)) .setSmallIcon(android.R.drawable.stat_notify_more) .setTicker(getString(R.string.notif_title)) .setContentIntent(PendingIntent.getActivity(this, 0, ui, 0)); mgr.notify(NOTIFY_ID, b.build());
public void showSendingNotification(Account account) { String accountName = notificationHelper.getAccountName(account); String title = resourceProvider.sendingMailTitle(); String tickerText = resourceProvider.sendingMailBody(accountName); int notificationId = NotificationIds.getFetchingMailNotificationId(account); String outboxFolder = account.getOutboxFolder(); PendingIntent showMessageListPendingIntent = actionBuilder.createViewFolderPendingIntent( account, outboxFolder, notificationId); NotificationCompat.Builder builder = notificationHelper.createNotificationBuilder(account, NotificationChannelManager.ChannelType.MISCELLANEOUS) .setSmallIcon(resourceProvider.getIconSendingMail()) .setWhen(System.currentTimeMillis()) .setOngoing(true) .setTicker(tickerText) .setContentTitle(title) .setContentText(accountName) .setContentIntent(showMessageListPendingIntent) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC); if (NOTIFICATION_LED_WHILE_SYNCING) { notificationHelper.configureNotification(builder, null, null, account.getNotificationSetting().getLedColor(), NOTIFICATION_LED_BLINK_FAST, true); } getNotificationManager().notify(notificationId, builder.build()); }
.setContentTitle(getString(R.string.notif_title)) .setContentText(Integer.toHexString(randomEvent.value)) .setSmallIcon(android.R.drawable.stat_notify_more) .setTicker(getString(R.string.notif_title)) .setContentIntent(PendingIntent.getActivity(this, 0, ui, 0)); mgr.notify(NOTIFY_ID, b.build());
private void raiseNotification(Intent inbound, File output, Exception e) { NotificationCompat.Builder b= new NotificationCompat.Builder(this, CHANNEL_WHATEVER); b.setAutoCancel(true).setWhen(System.currentTimeMillis()); if (e == null) { b.setContentTitle(getString(R.string.download_complete)) .setContentText(getString(R.string.fun)) .setSmallIcon(android.R.drawable.stat_sys_download_done); Intent outbound=new Intent(Intent.ACTION_VIEW); Uri outputUri= FileProvider.getUriForFile(this, AUTHORITY, output); outbound.setDataAndType(outputUri, inbound.getType()); outbound.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); PendingIntent pi=PendingIntent.getActivity(this, 0, outbound, PendingIntent.FLAG_UPDATE_CURRENT); b.setContentIntent(pi); } else { b.setContentTitle(getString(R.string.exception)) .setContentText(e.getMessage()) .setSmallIcon(android.R.drawable.stat_notify_error); } NotificationManager mgr= (NotificationManager)getSystemService(NOTIFICATION_SERVICE); mgr.notify(NOTIFY_ID, b.build()); }
.setContentTitle(getString(R.string.notif_title)) .setContentText(Integer.toHexString(randomEvent.value)) .setSmallIcon(android.R.drawable.stat_notify_more) .setTicker(getString(R.string.notif_title)) .setContentIntent(PendingIntent.getActivity(this, 0, ui, 0)); mgr.notify(NOTIFY_ID, b.build());
.setSound(null) .setContentIntent(pendingIntent) .setSmallIcon(R.drawable.ic_notification) .setShowWhen(true) .setColor(Color.GREEN) .setLocalOnly(true) .build();
public void showAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); PendingIntent editServerSettingsPendingIntent = createContentIntent(account, incoming); String title = resourceProvider.authenticationErrorTitle(); String text = resourceProvider.authenticationErrorBody(account.getDescription()); NotificationCompat.Builder builder = notificationHelper .createNotificationBuilder(account, NotificationChannelManager.ChannelType.MISCELLANEOUS) .setSmallIcon(resourceProvider.getIconWarning()) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setTicker(title) .setContentTitle(title) .setContentText(text) .setContentIntent(editServerSettingsPendingIntent) .setStyle(new BigTextStyle().bigText(text)) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_ERROR); notificationHelper.configureNotification(builder, null, null, NOTIFICATION_LED_FAILURE_COLOR, NOTIFICATION_LED_BLINK_FAST, true); getNotificationManager().notify(notificationId, builder.build()); }
private void foregroundify() { 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)); } NotificationCompat.Builder b= new NotificationCompat.Builder(this, CHANNEL_WHATEVER); b.setAutoCancel(true) .setDefaults(Notification.DEFAULT_ALL); b.setContentTitle(getString(R.string.app_name)) .setSmallIcon(R.mipmap.ic_launcher) .setTicker(getString(R.string.app_name)); b.addAction(R.drawable.ic_record_white_24dp, getString(R.string.notify_record), buildPendingIntent(ACTION_RECORD)); b.addAction(R.drawable.ic_eject_white_24dp, getString(R.string.notify_shutdown), buildPendingIntent(ACTION_SHUTDOWN)); startForeground(NOTIFY_ID, b.build()); }
public void showCertificateErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getCertificateErrorNotificationId(account, incoming); PendingIntent editServerSettingsPendingIntent = createContentIntent(account, incoming); String title = resourceProvider.certificateErrorTitle(account.getDescription()); String text = resourceProvider.certificateErrorBody(); NotificationCompat.Builder builder = notificationHelper .createNotificationBuilder(account, NotificationChannelManager.ChannelType.MISCELLANEOUS) .setSmallIcon(resourceProvider.getIconWarning()) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setTicker(title) .setContentTitle(title) .setContentText(text) .setContentIntent(editServerSettingsPendingIntent) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_ERROR); notificationHelper.configureNotification(builder, null, null, NOTIFICATION_LED_FAILURE_COLOR, NOTIFICATION_LED_BLINK_FAST, true); getNotificationManager().notify(notificationId, builder.build()); }