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;
}
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);
}
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);
}
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);
}
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);
}
}
Aggregations