本文整理汇总了Java中android.support.v4.app.NotificationCompat.Action方法的典型用法代码示例。如果您正苦于以下问题:Java NotificationCompat.Action方法的具体用法?Java NotificationCompat.Action怎么用?Java NotificationCompat.Action使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.app.NotificationCompat
的用法示例。
在下文中一共展示了NotificationCompat.Action方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAction
import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private NotificationCompat.Action getAction(AppUpdateStatusManager.AppUpdateStatus entry) {
if (entry.intent != null) {
switch (entry.status) {
case UpdateAvailable:
return new NotificationCompat.Action(R.drawable.ic_file_download, context.getString(R.string.notification_action_update), entry.intent);
case Downloading:
case Installing:
return new NotificationCompat.Action(R.drawable.ic_cancel, context.getString(R.string.notification_action_cancel), entry.intent);
case ReadyToInstall:
return new NotificationCompat.Action(R.drawable.ic_file_install, context.getString(R.string.notification_action_install), entry.intent);
}
}
return null;
}
示例2: getServiceNotificationAction
import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private static NotificationCompat.Action getServiceNotificationAction(Context context, String action, int iconResId, int titleResId) {
Intent intent = new Intent(context, WebRtcCallService.class);
intent.setAction(action);
PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, 0);
return new NotificationCompat.Action(iconResId, context.getString(titleResId), pendingIntent);
}
示例3: createNotification
import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
public static void createNotification(Service context) {
// Create Pending Intents.
PendingIntent piLaunchMainActivity = getLaunchActivityPI(context);
PendingIntent piStopService = getStopServicePI(context);
// Action to stop the service.
NotificationCompat.Action stopAction =
new NotificationCompat.Action.Builder(
STOP_ACTION_ICON,
getNotificationStopActionText(context),
piStopService)
.build();
// Create a notification.
Notification mNotification =
new NotificationCompat.Builder(context)
.setContentTitle(getNotificationTitle(context))
.setContentText(getNotificationContent(context))
.setSmallIcon(SMALL_ICON)
.setContentIntent(piLaunchMainActivity)
.addAction(stopAction)
.setStyle(new NotificationCompat.BigTextStyle())
.build();
context.startForeground(ONGOING_NOTIFICATION_ID, mNotification);
}
示例4: addDeleteAllAction
import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private void addDeleteAllAction(WearableExtender wearableExtender, NotificationData notificationData) {
int icon = R.drawable.ic_action_delete_dark;
String title = context.getString(R.string.notification_action_delete_all);
Account account = notificationData.getAccount();
ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences();
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
PendingIntent action = actionCreator.getDeleteAllPendingIntent(account, messageReferences, notificationId);
NotificationCompat.Action deleteAction = new NotificationCompat.Action.Builder(icon, title, action).build();
wearableExtender.addAction(deleteAction);
}
示例5: addArchiveAllAction
import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private void addArchiveAllAction(WearableExtender wearableExtender, NotificationData notificationData) {
int icon = R.drawable.ic_action_archive_dark;
String title = context.getString(R.string.notification_action_archive_all);
Account account = notificationData.getAccount();
ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences();
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
PendingIntent action = actionCreator.createArchiveAllPendingIntent(account, messageReferences, notificationId);
NotificationCompat.Action archiveAction = new NotificationCompat.Action.Builder(icon, title, action).build();
wearableExtender.addAction(archiveAction);
}
示例6: addReplyAction
import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private void addReplyAction(WearableExtender wearableExtender, NotificationHolder holder) {
int icon = R.drawable.ic_action_single_message_options_dark;
String title = context.getString(R.string.notification_action_reply);
MessageReference messageReference = holder.content.messageReference;
int notificationId = holder.notificationId;
PendingIntent action = actionCreator.createReplyPendingIntent(messageReference, notificationId);
NotificationCompat.Action replyAction = new NotificationCompat.Action.Builder(icon, title, action).build();
wearableExtender.addAction(replyAction);
}
示例7: addMarkAsReadAction
import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private void addMarkAsReadAction(WearableExtender wearableExtender, NotificationHolder holder) {
int icon = R.drawable.ic_action_mark_as_read_dark;
String title = context.getString(R.string.notification_action_mark_as_read);
MessageReference messageReference = holder.content.messageReference;
int notificationId = holder.notificationId;
PendingIntent action = actionCreator.createMarkMessageAsReadPendingIntent(messageReference, notificationId);
NotificationCompat.Action markAsReadAction = new NotificationCompat.Action.Builder(icon, title, action).build();
wearableExtender.addAction(markAsReadAction);
}
示例8: addDeleteAction
import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private void addDeleteAction(WearableExtender wearableExtender, NotificationHolder holder) {
int icon = R.drawable.ic_action_delete_dark;
String title = context.getString(R.string.notification_action_delete);
MessageReference messageReference = holder.content.messageReference;
int notificationId = holder.notificationId;
PendingIntent action = actionCreator.createDeleteMessagePendingIntent(messageReference, notificationId);
NotificationCompat.Action deleteAction = new NotificationCompat.Action.Builder(icon, title, action).build();
wearableExtender.addAction(deleteAction);
}
示例9: addArchiveAction
import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private void addArchiveAction(WearableExtender wearableExtender, NotificationHolder holder) {
int icon = R.drawable.ic_action_archive_dark;
String title = context.getString(R.string.notification_action_archive);
MessageReference messageReference = holder.content.messageReference;
int notificationId = holder.notificationId;
PendingIntent action = actionCreator.createArchiveMessagePendingIntent(messageReference, notificationId);
NotificationCompat.Action archiveAction = new NotificationCompat.Action.Builder(icon, title, action).build();
wearableExtender.addAction(archiveAction);
}
示例10: MediaNotificationManager
import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
public MediaNotificationManager(MusicService service) {
mService = service;
mNotificationManager =
(NotificationManager) mService.getSystemService(Context.NOTIFICATION_SERVICE);
mPlayAction =
new NotificationCompat.Action(
R.drawable.ic_play_arrow_white_24dp,
mService.getString(R.string.label_play),
MediaButtonReceiver.buildMediaButtonPendingIntent(
mService,
PlaybackStateCompat.ACTION_PLAY));
mPauseAction =
new NotificationCompat.Action(
R.drawable.ic_pause_white_24dp,
mService.getString(R.string.label_pause),
MediaButtonReceiver.buildMediaButtonPendingIntent(
mService,
PlaybackStateCompat.ACTION_PAUSE));
mNextAction =
new NotificationCompat.Action(
R.drawable.ic_skip_next_white_24dp,
mService.getString(R.string.label_next),
MediaButtonReceiver.buildMediaButtonPendingIntent(
mService,
PlaybackStateCompat.ACTION_SKIP_TO_NEXT));
mPrevAction =
new NotificationCompat.Action(
R.drawable.ic_skip_previous_white_24dp,
mService.getString(R.string.label_previous),
MediaButtonReceiver.buildMediaButtonPendingIntent(
mService,
PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS));
// Cancel all notifications to handle the case where the Service was killed and
// restarted by the system.
mNotificationManager.cancelAll();
}
示例11: displayUserConfirmNotificationImpl
import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private void displayUserConfirmNotificationImpl(int accountId, int peerId, int messageId, @NonNull ExchangeMessage message, @NonNull OwnerInfo ownerInfo) {
if (Utils.hasOreo()) {
mNotificationManager.createNotificationChannel(AppNotificationChannels.getKeyExchangeChannel(this));
}
String targetContentText = getString(R.string.key_exchange_request_content_text, ownerInfo.getUser().getFullName());
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, AppNotificationChannels.KEY_EXCHANGE_CHANNEL_ID)
.setSmallIcon(R.drawable.ic_crypt_key_vector)
.setLargeIcon(ownerInfo.getAvatar())
.setContentTitle(getString(R.string.key_exchange_request))
.setContentText(targetContentText)
.setStyle(new NotificationCompat.BigTextStyle().bigText(targetContentText))
.setAutoCancel(true);
Intent intent = KeyExchangeCommitActivity.createIntent(this, accountId, peerId, ownerInfo.getUser(), messageId, message);
PendingIntent contentIntent = PendingIntent.getActivity(this, messageId, intent, PendingIntent.FLAG_CANCEL_CURRENT);
builder.setContentIntent(contentIntent);
Intent apply = createIntentForApply(this, message, accountId, peerId, messageId);
PendingIntent quickPendingIntent = PendingIntent.getService(this, messageId, apply, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Action applyAction = new NotificationCompat.Action(R.drawable.check, getString(R.string.apply), quickPendingIntent);
builder.addAction(applyAction);
builder.setPriority(NotificationCompat.PRIORITY_HIGH);
builder.setDefaults(NotificationCompat.DEFAULT_ALL);
Notification notification = builder.build();
mNotificationManager.notify(String.valueOf(message.getSessionId()), NOTIFICATION_KEY_EXCHANGE_REQUEST, notification);
}
示例12: getActivityNotificationAction
import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private static NotificationCompat.Action getActivityNotificationAction(@NonNull Context context, @NonNull String action,
@DrawableRes int iconResId, @StringRes int titleResId)
{
Intent intent = new Intent(context, WebRtcCallActivity.class);
intent.setAction(action);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
return new NotificationCompat.Action(iconResId, context.getString(titleResId), pendingIntent);
}
示例13: showIncomingCallNotification
import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
public static void showIncomingCallNotification(Context context, String accountID, int callID) {
mNotificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
Intent activityIntent = new Intent(context, MainActivity.class);
activityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
activityIntent.putExtra(context.getString(R.string.param_call_id), callID);
activityIntent.putExtra(context.getString(R.string.param_incoming_call), true);
Intent actionIntent = new Intent(context.getString(R.string.package_name) + "." + context.getString(R.string.notif_incoming_call_intent_action));
actionIntent.putExtra(context.getString(R.string.param_account_id), accountID);
actionIntent.putExtra(context.getString(R.string.param_call_id), callID);
PendingIntent pActivityIntent = PendingIntent.getActivity(context, (int) System.currentTimeMillis(), activityIntent, 0);
PendingIntent pActionIntent = PendingIntent.getBroadcast(context, (int) System.currentTimeMillis(), actionIntent, 0);
NotificationCompat.Action acceptCallAction = new NotificationCompat.Action.Builder(R.drawable.ic_call, context.getString(R.string.notif_incoming_call_action_accept), pActionIntent).build();
Notification n = new NotificationCompat.Builder(context)
.setContentTitle(context.getString(R.string.notif_incoming_call_title))
.setContentText(context.getString(R.string.notif_incoming_call_text))
.setSmallIcon(R.drawable.ic_call)
.setContentIntent(pActivityIntent)
.setAutoCancel(true)
.addAction(acceptCallAction)
.build();
mNotificationManager.notify(mNotifID, n);
}
示例14: showOng
import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
public void showOng() {
Intent dialIntent = new Intent(ctx, InCall.class);
dialIntent.putExtra("incomingnumber", num);
dialIntent.putExtra("incomingname", n);
PendingIntent intent1 = PendingIntent.getActivity(ctx, 0, dialIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Intent dismissReceive = new Intent();
dismissReceive.setAction(InCallManager.DISMISS);
PendingIntent intentDismiss = PendingIntent.getBroadcast(ctx, 0, dismissReceive, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Action dismissAction = new NotificationCompat.Action.Builder(R.drawable.ic_call_end_black_24dp, "HANG UP", intentDismiss).build();
NotificationManager notificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
String id = "caller_id_ongoing_channel";
String name = "caller_id_ongoing_notifications";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
createChannel(notificationManager, id, name, NotificationManager.IMPORTANCE_DEFAULT);
}
NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(ctx, name);
notifBuilder.setLargeIcon(BitmapFactory.decodeResource(ctx.getResources(), R.mipmap.ic_launcher))
.setDefaults(Notification.DEFAULT_ALL)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
// .setCategory(Notification.CATEGORY_CALL)
// .setFullScreenIntent(intent1, true)
.addAction(dismissAction)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setContentTitle(n)
.setContentText("Ongoing call " + num)
.setSmallIcon(R.drawable.ic_call_black_24dp)
.setContentIntent(intent1)
.setChannelId(id)
.setOngoing(true)
.setShowWhen(true)
.setAutoCancel(false);
// notifBuilder.flags = android.app.Notification.DEFAULT_LIGHTS | android.app.Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(766, notifBuilder.build());
}
示例15: sendNotificationForConversation
import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private void sendNotificationForConversation(
int conversationId,
String sender,
String message,
long timestamp) {
// A pending Intent for reads.
PendingIntent readPendingIntent = PendingIntent.getBroadcast(
getApplicationContext(),
conversationId,
getMessageReadIntent(conversationId),
PendingIntent.FLAG_UPDATE_CURRENT);
// Building a Pending Intent for the reply action to trigger.
PendingIntent replyIntent = PendingIntent.getBroadcast(
getApplicationContext(),
conversationId,
getMessageReplyIntent(conversationId),
PendingIntent.FLAG_UPDATE_CURRENT);
/// TODO: Add the code to create the UnreadConversation.
/// End create UnreadConversation.
/// TODO: Add the code to allow in-line reply on Wear 2.0.
/// End in-line action for Wear 2.0.
// Add an action to allow replies.
NotificationCompat.Action replyAction =
new NotificationCompat.Action.Builder(
R.drawable.ic_reply_white_24dp,
getString(R.string.reply_action),
replyIntent)
/// TODO: Add better wear support.
.build();
// Add messages with the MessagingStyle notification.
NotificationCompat.MessagingStyle messagingStyle =
new NotificationCompat.MessagingStyle(sender)
.addMessage(message, timestamp, sender);
NotificationCompat.Builder builder =
new NotificationCompat.Builder(getApplicationContext())
.setStyle(messagingStyle)
.setDefaults(NotificationCompat.DEFAULT_VIBRATE)
.setSmallIcon(R.drawable.notification_icon)
.setLargeIcon(BitmapFactory.decodeResource(
getApplicationContext().getResources(), R.drawable.android_contact))
.setContentText(message)
.setWhen(timestamp)
.addAction(replyAction)
.setContentTitle(sender)
.setContentIntent(readPendingIntent)
/// TODO: Extend the notification with CarExtender.
/// End
;
Log.d(TAG, "Sending notification " + conversationId + " conversation: " + message);
NotificationManagerCompat.from(this).notify(conversationId, builder.build());
}