Search in sources :

Example 31 with Builder

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

the class DeviceNotifications method createInboxStyleSummaryNotification.

private NotificationCompat.Builder createInboxStyleSummaryNotification(Account account, NotificationData notificationData, int unreadMessageCount) {
    NotificationHolder latestNotification = notificationData.getHolderForLatestNotification();
    int newMessagesCount = notificationData.getNewMessagesCount();
    String accountName = controller.getAccountName(account);
    String title = context.getResources().getQuantityString(R.plurals.notification_new_messages_title, newMessagesCount, newMessagesCount);
    String summary = (notificationData.hasSummaryOverflowMessages()) ? context.getString(R.string.notification_additional_messages, notificationData.getSummaryOverflowMessagesCount(), accountName) : accountName;
    String groupKey = NotificationGroupKeys.getGroupKey(account);
    NotificationCompat.Builder builder = createAndInitializeNotificationBuilder(account).setNumber(unreadMessageCount).setTicker(latestNotification.content.summary).setGroup(groupKey).setGroupSummary(true).setContentTitle(title).setSubText(accountName);
    NotificationCompat.InboxStyle style = createInboxStyle(builder).setBigContentTitle(title).setSummaryText(summary);
    for (NotificationContent content : notificationData.getContentForSummaryNotification()) {
        style.addLine(content.summary);
    }
    builder.setStyle(style);
    addMarkAllAsReadAction(builder, notificationData);
    addDeleteAllAction(builder, notificationData);
    wearNotifications.addSummaryActions(builder, notificationData);
    int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
    List<MessageReference> messageReferences = notificationData.getAllMessageReferences();
    PendingIntent contentIntent = actionCreator.createViewMessagesPendingIntent(account, messageReferences, notificationId);
    builder.setContentIntent(contentIntent);
    return builder;
}
Also used : Builder(android.support.v4.app.NotificationCompat.Builder) NotificationCompat(android.support.v4.app.NotificationCompat) InboxStyle(android.support.v4.app.NotificationCompat.InboxStyle) PendingIntent(android.app.PendingIntent) MessageReference(com.fsck.k9.activity.MessageReference)

Example 32 with Builder

use of android.support.v4.app.NotificationCompat.Builder in project AndroidTraining by mixi-inc.

the class NotificationActivity1 method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_notification1);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    Notification notification = builder.setSmallIcon(R.drawable.ic_launcher).setContentTitle("通知テスト").setContentText("通知の詳細テスト").setTicker("通知ティッカーテスト").setVibrate(// 3秒間バイブレーションが作動
    new long[] { 3000 }).build();
    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    manager.notify(0, notification);
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Notification(android.app.Notification)

Example 33 with Builder

use of android.support.v4.app.NotificationCompat.Builder in project AndroidTraining by mixi-inc.

the class NotificationActivity2 method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_notification2);
    Intent intent = new Intent();
    intent.setAction(ACTION_VIEW_MY_OWN);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    Notification notification = builder.setSmallIcon(R.drawable.ic_launcher).setContentTitle("通知テスト").setContentText("通知の詳細テスト").setContentIntent(pendingIntent).build();
    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    manager.notify(0, notification);
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification)

Example 34 with Builder

use of android.support.v4.app.NotificationCompat.Builder in project AndroidTraining by mixi-inc.

the class NotificationActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_notification);
    Intent intent = new Intent(this, NotificationSubActivity.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    Notification notification = builder.setSmallIcon(R.drawable.ic_launcher).setContentTitle("通知テスト").setContentText("通知の詳細テスト").setContentIntent(// 通知をタップした時に使う PendingIntent
    pendingIntent).setOnlyAlertOnce(// この通知が未だ表示されていない時だけ、音やバイブレーション、ショートメッセージの表示を行う
    true).setAutoCancel(// タップしたら消えるようにする
    true).build();
    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    manager.notify(0, notification);
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification)

Example 35 with Builder

use of android.support.v4.app.NotificationCompat.Builder in project qksms by moezbhatti.

the class NotificationManager method initQuickCompose.

/**
     * Set up the QK Compose notification
     *
     * @param override       If true, then show the QK Compose notification regardless of the user's preference
     * @param overrideCancel If true, dismiss the notification no matter what
     */
public static void initQuickCompose(Context context, boolean override, boolean overrideCancel) {
    if (sPrefs == null) {
        init(context);
    }
    if (sPrefs.getBoolean(SettingsFragment.QUICKCOMPOSE, false) || override) {
        Intent composeIntent = new Intent(context, QKComposeActivity.class);
        PendingIntent composePI = PendingIntent.getActivity(context, 9, composeIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setContentTitle(sRes.getString(R.string.quickcompose)).setContentText(sRes.getString(R.string.quickcompose_detail)).setOngoing(true).setContentIntent(composePI).setSmallIcon(R.drawable.ic_compose).setPriority(NotificationCompat.PRIORITY_MIN).setColor(ThemeManager.getColor());
        NotificationManager.notify(context, NOTIFICATION_ID_QUICKCOMPOSE, builder.build());
    } else {
        dismiss(context, NOTIFICATION_ID_QUICKCOMPOSE);
    }
    if (overrideCancel) {
        dismiss(context, NOTIFICATION_ID_QUICKCOMPOSE);
    }
}
Also used : NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) 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