Search in sources :

Example 91 with Builder

use of android.support.v4.app.NotificationCompat.Builder in project Klyph by jonathangerbaud.

the class KlyphNotification method sendNotification.

public static void sendNotification(Context context, Builder builder) {
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
    Intent resultIntent = new Intent(context, MainActivity.class);
    resultIntent.putExtra(KlyphBundleExtras.SHOW_NOTIFICATION_MENU, true);
    stackBuilder.addNextIntentWithParentStack(resultIntent);
    int intentCode = (int) Math.round(Math.random() * 1000000);
    // Gets a PendingIntent containing the entire back stack
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(intentCode, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(resultPendingIntent);
    Intent intent = new Intent(context, NotificationGroupDeletedReceiver.class);
    builder.setDeleteIntent(PendingIntent.getBroadcast(context.getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT));
    final NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    final String tag = context.getPackageName() + "_grouped";
    final int id = 0;
    // pair (tag, id) must be unique
    // tag is the unique key
    mNotificationManager.notify(tag, id, builder.build());
}
Also used : NotificationManager(android.app.NotificationManager) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) TaskStackBuilder(android.support.v4.app.TaskStackBuilder)

Example 92 with Builder

use of android.support.v4.app.NotificationCompat.Builder in project Talon-for-Twitter by klinker24.

the class TrimDataService method notifyNewVersion.

public void notifyNewVersion(String version) {
    Intent goToStore = new Intent(this, RedirectToPlayStore.class);
    PendingIntent storePending = PendingIntent.getActivity(this, 0, goToStore, 0);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    builder.setContentTitle("Talon Version " + version);
    builder.setContentText("Click to update.");
    builder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher));
    builder.setSmallIcon(R.drawable.ic_stat_icon);
    builder.setContentIntent(storePending);
    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
    notificationManager.notify(552, builder.build());
}
Also used : NotificationManagerCompat(android.support.v4.app.NotificationManagerCompat) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 93 with Builder

use of android.support.v4.app.NotificationCompat.Builder in project k-9 by k9mail.

the class AuthenticationErrorNotifications method showAuthenticationErrorNotification.

public void showAuthenticationErrorNotification(Account account, boolean incoming) {
    int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming);
    Context context = controller.getContext();
    PendingIntent editServerSettingsPendingIntent = createContentIntent(context, account, incoming);
    String title = context.getString(R.string.notification_authentication_error_title);
    String text = context.getString(R.string.notification_authentication_error_text, account.getDescription());
    NotificationCompat.Builder builder = controller.createNotificationBuilder().setSmallIcon(R.drawable.notification_icon_warning).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);
    controller.configureNotification(builder, null, null, NOTIFICATION_LED_FAILURE_COLOR, NOTIFICATION_LED_BLINK_FAST, true);
    getNotificationManager().notify(notificationId, builder.build());
}
Also used : Context(android.content.Context) BigTextStyle(android.support.v4.app.NotificationCompat.BigTextStyle) NotificationCompat(android.support.v4.app.NotificationCompat) PendingIntent(android.app.PendingIntent)

Example 94 with Builder

use of android.support.v4.app.NotificationCompat.Builder in project k-9 by k9mail.

the class CertificateErrorNotifications method showCertificateErrorNotification.

public void showCertificateErrorNotification(Account account, boolean incoming) {
    int notificationId = NotificationIds.getCertificateErrorNotificationId(account, incoming);
    Context context = controller.getContext();
    PendingIntent editServerSettingsPendingIntent = createContentIntent(context, account, incoming);
    String title = context.getString(R.string.notification_certificate_error_title, account.getDescription());
    String text = context.getString(R.string.notification_certificate_error_text);
    NotificationCompat.Builder builder = controller.createNotificationBuilder().setSmallIcon(getCertificateErrorNotificationIcon()).setWhen(System.currentTimeMillis()).setAutoCancel(true).setTicker(title).setContentTitle(title).setContentText(text).setContentIntent(editServerSettingsPendingIntent).setVisibility(NotificationCompat.VISIBILITY_PUBLIC).setCategory(NotificationCompat.CATEGORY_ERROR);
    controller.configureNotification(builder, null, null, NOTIFICATION_LED_FAILURE_COLOR, NOTIFICATION_LED_BLINK_FAST, true);
    getNotificationManager().notify(notificationId, builder.build());
}
Also used : Context(android.content.Context) NotificationCompat(android.support.v4.app.NotificationCompat) PendingIntent(android.app.PendingIntent)

Example 95 with Builder

use of android.support.v4.app.NotificationCompat.Builder in project k-9 by k9mail.

the class DeviceNotifications method buildSummaryNotification.

public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) {
    int unreadMessageCount = notificationData.getUnreadMessageCount();
    NotificationCompat.Builder builder;
    if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) {
        builder = createSimpleSummaryNotification(account, unreadMessageCount);
    } else if (notificationData.isSingleMessageNotification()) {
        NotificationHolder holder = notificationData.getHolderForLatestNotification();
        builder = createBigTextStyleSummaryNotification(account, holder);
    } else {
        builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount);
    }
    if (notificationData.containsStarredMessages()) {
        builder.setPriority(NotificationCompat.PRIORITY_HIGH);
    }
    int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
    PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent(account, notificationId);
    builder.setDeleteIntent(deletePendingIntent);
    lockScreenNotification.configureLockScreenNotification(builder, notificationData);
    boolean ringAndVibrate = false;
    if (!silent && !account.isRingNotified()) {
        account.setRingNotified(true);
        ringAndVibrate = true;
    }
    NotificationSetting notificationSetting = account.getNotificationSetting();
    controller.configureNotification(builder, (notificationSetting.shouldRing()) ? notificationSetting.getRingtone() : null, (notificationSetting.shouldVibrate()) ? notificationSetting.getVibration() : null, (notificationSetting.isLed()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate);
    return builder.build();
}
Also used : Builder(android.support.v4.app.NotificationCompat.Builder) NotificationCompat(android.support.v4.app.NotificationCompat) NotificationSetting(com.fsck.k9.NotificationSetting) PendingIntent(android.app.PendingIntent)

Aggregations

NotificationCompat (android.support.v4.app.NotificationCompat)105 PendingIntent (android.app.PendingIntent)86 Intent (android.content.Intent)76 NotificationManager (android.app.NotificationManager)35 Notification (android.app.Notification)29 Builder (android.support.v4.app.NotificationCompat.Builder)19 Context (android.content.Context)16 TaskStackBuilder (android.support.v4.app.TaskStackBuilder)14 Uri (android.net.Uri)11 Bundle (android.os.Bundle)10 Bitmap (android.graphics.Bitmap)9 View (android.view.View)9 RemoteViews (android.widget.RemoteViews)9 IOException (java.io.IOException)9 AlertDialog (android.app.AlertDialog)7 DialogInterface (android.content.DialogInterface)7 Paint (android.graphics.Paint)6 SpannableString (android.text.SpannableString)6 TypedValue (android.util.TypedValue)6 TextView (android.widget.TextView)6