本文整理匯總了Java中android.support.v4.app.NotificationCompat.Builder.addAction方法的典型用法代碼示例。如果您正苦於以下問題:Java Builder.addAction方法的具體用法?Java Builder.addAction怎麽用?Java Builder.addAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.app.NotificationCompat.Builder
的用法示例。
在下文中一共展示了Builder.addAction方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addMarkAllAsReadAction
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void addMarkAllAsReadAction(Builder builder, NotificationData notificationData) {
int icon = getMarkAsReadActionIcon();
String title = context.getString(R.string.notification_action_mark_as_read);
Account account = notificationData.getAccount();
ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences();
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
PendingIntent markAllAsReadPendingIntent =
actionCreator.createMarkAllAsReadPendingIntent(account, messageReferences, notificationId);
builder.addAction(icon, title, markAllAsReadPendingIntent);
}
示例2: addDeleteAllAction
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void addDeleteAllAction(Builder builder, NotificationData notificationData) {
if (QMail.getNotificationQuickDeleteBehaviour() != NotificationQuickDelete.ALWAYS) {
return;
}
int icon = getDeleteActionIcon();
String title = context.getString(R.string.notification_action_delete);
Account account = notificationData.getAccount();
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences();
PendingIntent action = actionCreator.createDeleteAllPendingIntent(account, messageReferences, notificationId);
builder.addAction(icon, title, action);
}
示例3: addDeleteAction
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void addDeleteAction(Builder builder, NotificationContent content, int notificationId) {
if (!isDeleteActionEnabled()) {
return;
}
int icon = getDeleteActionIcon();
String title = context.getString(R.string.notification_action_delete);
MessageReference messageReference = content.messageReference;
PendingIntent action = actionCreator.createDeleteMessagePendingIntent(messageReference, notificationId);
builder.addAction(icon, title, action);
}
示例4: addReplyAction
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void addReplyAction(Builder builder, NotificationContent content, int notificationId) {
int icon = getReplyActionIcon();
String title = context.getString(R.string.notification_action_reply);
MessageReference messageReference = content.messageReference;
PendingIntent replyToMessagePendingIntent =
actionCreator.createReplyPendingIntent(messageReference, notificationId);
builder.addAction(icon, title, replyToMessagePendingIntent);
}
示例5: addDeviceReplyAction
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void addDeviceReplyAction(Builder builder, NotificationHolder holder) {
int icon = R.drawable.notification_action_mark_as_read;
String title = context.getString(R.string.notification_action_reply);
NotificationContent content = holder.content;
MessageReference messageReference = content.messageReference;
PendingIntent replyToMessagePendingIntent =
actionCreator.createReplyPendingIntent(messageReference, holder.notificationId);
builder.addAction(icon, title, replyToMessagePendingIntent);
}
示例6: addDeviceMarkAsReadAction
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void addDeviceMarkAsReadAction(Builder builder, NotificationHolder holder) {
int icon = R.drawable.notification_action_mark_as_read;
String title = context.getString(R.string.notification_action_mark_as_read);
NotificationContent content = holder.content;
int notificationId = holder.notificationId;
MessageReference messageReference = content.messageReference;
PendingIntent action = actionCreator.createMarkMessageAsReadPendingIntent(messageReference, notificationId);
builder.addAction(icon, title, action);
}
示例7: addDeviceDeleteAction
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void addDeviceDeleteAction(Builder builder, NotificationHolder holder) {
if (!isDeleteActionEnabled()) {
return;
}
int icon = R.drawable.notification_action_delete;
String title = context.getString(R.string.notification_action_delete);
NotificationContent content = holder.content;
int notificationId = holder.notificationId;
MessageReference messageReference = content.messageReference;
PendingIntent action = actionCreator.createDeleteMessagePendingIntent(messageReference, notificationId);
builder.addAction(icon, title, action);
}
示例8: addDeleteAllAction
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void addDeleteAllAction(Builder builder, NotificationData notificationData) {
if (K9.getNotificationQuickDeleteBehaviour() != NotificationQuickDelete.ALWAYS) {
return;
}
int icon = getDeleteActionIcon();
String title = context.getString(R.string.notification_action_delete);
Account account = notificationData.getAccount();
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences();
PendingIntent action = actionCreator.createDeleteAllPendingIntent(account, messageReferences, notificationId);
builder.addAction(icon, title, action);
}
示例9: buildSingleConversations
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private Builder buildSingleConversations(final boolean notify) {
final Builder mBuilder = new NotificationCompat.Builder(
mXmppConnectionService);
final ArrayList<Message> messages = notifications.values().iterator().next();
if (messages.size() >= 1) {
final Conversation conversation = messages.get(0).getConversation();
mBuilder.setLargeIcon(mXmppConnectionService.getAvatarService()
.get(conversation, getPixel(64)));
mBuilder.setContentTitle(conversation.getName());
if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
int count = messages.size();
mBuilder.setContentText(mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages,count,count));
} else {
Message message;
if ((message = getImage(messages)) != null) {
modifyForImage(mBuilder, message, messages, notify);
} else if (conversation.getMode() == Conversation.MODE_MULTI) {
modifyForConference(mBuilder, conversation, messages, notify);
} else {
modifyForTextOnly(mBuilder, messages, notify);
}
if ((message = getFirstDownloadableMessage(messages)) != null) {
mBuilder.addAction(
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ?
R.drawable.ic_file_download_white_24dp : R.drawable.ic_action_download,
mXmppConnectionService.getResources().getString(R.string.download_x_file,
UIHelper.getFileDescriptionString(mXmppConnectionService, message)),
createDownloadIntent(message)
);
}
if ((message = getFirstLocationMessage(messages)) != null) {
mBuilder.addAction(R.drawable.ic_room_white_24dp,
mXmppConnectionService.getString(R.string.show_location),
createShowLocationIntent(message));
}
}
mBuilder.setContentIntent(createContentIntent(conversation));
}
return mBuilder;
}
示例10: updateColumn
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private static void updateColumn (final Context context, final DbInterface db, final Column col, final NotificationManager nm) {
final int nId = idForColumn(col);
final int count = db.getUnreadCount(col);
if (count > 0) {
final Intent showMainActI = new Intent(context, MainActivity.class)
.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
.putExtra(MainActivity.ARG_FOCUS_COLUMN_ID, col.getId());
final PendingIntent showMainActPi = PendingIntent.getActivity(context, col.getId(), showMainActI, PendingIntent.FLAG_CANCEL_CURRENT);
final List<Tweet> tweets = db.getTweets(col.getId(), Math.min(count, 5),
Selection.FILTERED, col.getExcludeColumnIds(),
col.getInlineMediaStyle() == InlineMediaStyle.SEAMLESS,
col.getNotificationStyle().isExcludeRetweets(),
!col.getNotificationStyle().isIncludeOwnTweets());
final String msg = makeMsg(col, tweets, count);
final Style style = makePreview(tweets, count);
final PendingIntent markAsReadPi = MarkAsReadReceiver.makePi(context, col, tweets);
final Builder nb = new NotificationCompat.Builder(context)
.setOnlyAlertOnce(true)
.setSmallIcon(notificationIcon())
.setContentTitle(col.getTitle())
.setContentText(msg)
.setTicker(msg)
.setNumber(count)
.setContentIntent(showMainActPi)
.setAutoCancel(true)
.setWhen(System.currentTimeMillis())
.setStyle(style);
if (markAsReadPi != null) nb.addAction(android.R.drawable.ic_menu_close_clear_cancel, "Mark as read", markAsReadPi); //ES
applyStyle(nb, col.getNotificationStyle());
nm.notify(nId, nb.build());
}
else {
nm.cancel(nId);
}
}
示例11: buildSingleConversations
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private Builder buildSingleConversations(final ArrayList<Message> messages) {
final Builder mBuilder = new NotificationCompat.Builder(mXmppConnectionService);
if (messages.size() >= 1) {
final Conversation conversation = messages.get(0).getConversation();
final UnreadConversation.Builder mUnreadBuilder = new UnreadConversation.Builder(conversation.getName());
mBuilder.setLargeIcon(mXmppConnectionService.getAvatarService()
.get(conversation, getPixel(64)));
mBuilder.setContentTitle(conversation.getName());
if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
int count = messages.size();
mBuilder.setContentText(mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages,count,count));
} else {
Message message;
if ((message = getImage(messages)) != null) {
modifyForImage(mBuilder, mUnreadBuilder, message, messages);
} else {
modifyForTextOnly(mBuilder, mUnreadBuilder, messages);
}
RemoteInput remoteInput = new RemoteInput.Builder("text_reply").setLabel(UIHelper.getMessageHint(mXmppConnectionService, conversation)).build();
NotificationCompat.Action markReadAction = new NotificationCompat.Action.Builder(R.drawable.ic_send_text_offline, "Mark As Read", createReadPendingIntent(conversation)).build();
NotificationCompat.Action replyAction = new NotificationCompat.Action.Builder(R.drawable.ic_send_text_offline, "Reply", createReplyIntent(conversation, false)).addRemoteInput(remoteInput).build();
NotificationCompat.Action wearReplyAction = new NotificationCompat.Action.Builder(R.drawable.ic_wear_reply, "Reply", createReplyIntent(conversation, true)).addRemoteInput(remoteInput).build();
mBuilder.extend(new NotificationCompat.WearableExtender().addAction(wearReplyAction));
mUnreadBuilder.setReplyAction(createReplyIntent(conversation, true), remoteInput);
mUnreadBuilder.setReadPendingIntent(createReadPendingIntent(conversation));
mBuilder.extend(new NotificationCompat.CarExtender().setUnreadConversation(mUnreadBuilder.build()));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
mBuilder.addAction(markReadAction);
mBuilder.addAction(replyAction);
}
if ((message = getFirstDownloadableMessage(messages)) != null) {
mBuilder.addAction(
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ?
R.drawable.ic_file_download_white_24dp : R.drawable.ic_action_download,
mXmppConnectionService.getResources().getString(R.string.download_x_file,
UIHelper.getFileDescriptionString(mXmppConnectionService, message)),
createDownloadIntent(message)
);
}
if ((message = getFirstLocationMessage(messages)) != null) {
mBuilder.addAction(R.drawable.ic_room_white_24dp,
mXmppConnectionService.getString(R.string.show_location),
createShowLocationIntent(message));
}
}
if (conversation.getMode() == Conversation.MODE_SINGLE) {
Contact contact = conversation.getContact();
Uri systemAccount = contact.getSystemAccount();
if (systemAccount != null) {
mBuilder.addPerson(systemAccount.toString());
}
}
mBuilder.setWhen(conversation.getLatestMessage().getTimeSent());
mBuilder.setSmallIcon(R.drawable.ic_notification);
mBuilder.setDeleteIntent(createDeleteIntent(conversation));
mBuilder.setContentIntent(createContentIntent(conversation));
}
return mBuilder;
}
示例12: buildSingleConversations
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private Builder buildSingleConversations(final ArrayList<Message> messages) {
final Builder mBuilder = new NotificationCompat.Builder(mXmppConnectionService);
if (messages.size() >= 1) {
final Conversation conversation = messages.get(0).getConversation();
final UnreadConversation.Builder mUnreadBuilder = new UnreadConversation.Builder(conversation.getName());
mBuilder.setLargeIcon(mXmppConnectionService.getAvatarService()
.get(conversation, getPixel(64)));
mBuilder.setContentTitle(conversation.getName());
if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
int count = messages.size();
mBuilder.setContentText(mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages, count, count));
} else {
Message message;
if ((message = getImage(messages)) != null) {
modifyForImage(mBuilder, mUnreadBuilder, message, messages);
} else {
modifyForTextOnly(mBuilder, mUnreadBuilder, messages);
}
RemoteInput remoteInput = new RemoteInput.Builder("text_reply").setLabel(UIHelper.getMessageHint(mXmppConnectionService, conversation)).build();
NotificationCompat.Action markReadAction = new NotificationCompat.Action.Builder(R.drawable.ic_send_text_offline, mXmppConnectionService.getResources().getString(R.string.mark_as_read), createReadPendingIntent(conversation)).build();
NotificationCompat.Action replyAction = new NotificationCompat.Action.Builder(R.drawable.ic_send_text_offline, mXmppConnectionService.getResources().getString(R.string.reply), createReplyIntent(conversation, false)).addRemoteInput(remoteInput).build();
NotificationCompat.Action wearReplyAction = new NotificationCompat.Action.Builder(R.drawable.ic_wear_reply, "Reply", createReplyIntent(conversation, true)).addRemoteInput(remoteInput).build();
mBuilder.extend(new NotificationCompat.WearableExtender().addAction(wearReplyAction));
mUnreadBuilder.setReplyAction(createReplyIntent(conversation, true), remoteInput);
mUnreadBuilder.setReadPendingIntent(createReadPendingIntent(conversation));
mBuilder.extend(new NotificationCompat.CarExtender().setUnreadConversation(mUnreadBuilder.build()));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
mBuilder.addAction(markReadAction);
mBuilder.addAction(replyAction);
}
if ((message = getFirstDownloadableMessage(messages)) != null) {
mBuilder.addAction(
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ?
R.drawable.ic_file_download_white_24dp : R.drawable.ic_action_download,
mXmppConnectionService.getResources().getString(R.string.download_x_file,
UIHelper.getFileDescriptionString(mXmppConnectionService, message)),
createDownloadIntent(message)
);
}
if ((message = getFirstLocationMessage(messages)) != null) {
mBuilder.addAction(R.drawable.ic_room_white_24dp,
mXmppConnectionService.getString(R.string.show_location),
createShowLocationIntent(message));
}
}
if (conversation.getMode() == Conversation.MODE_SINGLE) {
Contact contact = conversation.getContact();
Uri systemAccount = contact.getSystemAccount();
if (systemAccount != null) {
mBuilder.addPerson(systemAccount.toString());
}
}
mBuilder.setWhen(conversation.getLatestMessage().getTimeSent());
mBuilder.setSmallIcon(R.drawable.ic_notification);
mBuilder.setDeleteIntent(createDeleteIntent(conversation));
mBuilder.setContentIntent(createContentIntent(conversation));
}
return mBuilder;
}
示例13: addMarkAsReadAction
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void addMarkAsReadAction(Builder builder, NotificationContent content, int notificationId) {
int icon = getMarkAsReadActionIcon();
String title = context.getString(R.string.notification_action_mark_as_read);
MessageReference messageReference = content.messageReference;
PendingIntent action = actionCreator.createMarkMessageAsReadPendingIntent(messageReference, notificationId);
builder.addAction(icon, title, action);
}