remoteInput.setLabel(notificationConfig.commentPrompt()); notification.addAction(new NotificationCompat.Action.Builder(notificationConfig.resSendWithCommentButtonIcon(), notificationConfig.sendWithCommentButtonText(), sendIntent) .addRemoteInput(remoteInput.build()).build());
new NotificationCompat.Action.Builder(android.R.drawable.ic_delete, "Dismiss", dismissIntent) .build(); PendingIntent replyIntent = PendingIntent.getBroadcast(this, (int) System.currentTimeMillis(), intent, PendingIntent.FLAG_ONE_SHOT); NotificationCompat.Action replyAction = new NotificationCompat.Action.Builder(android.R.drawable.ic_input_add, reply.getValue(), replyIntent).build(); wearableExtender.addAction(replyAction);
PendingIntent replyIntent = PendingIntent.getBroadcast(context, (int) System.currentTimeMillis(), intent, PendingIntent.FLAG_ONE_SHOT); NotificationCompat.Action replyAction = new NotificationCompat.Action.Builder(android.R.drawable.ic_input_add, reply.getValue(), replyIntent).build(); wearableExtender.addAction(replyAction);
builder.addAction(new NotificationCompat.Action.Builder(0, action.getLabel(), pendingIntent).build());
abortIntent.putExtra(NOTIFICATION_ID_KEY, APPTENTIVE_NOTIFICATION_ID); PendingIntent abortPendingIntent = PendingIntent.getBroadcast(context, 0, abortIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action abortAction = new NotificationCompat.Action.Builder(0, "Discard", abortPendingIntent).build(); NotificationCompat.Action sendLogsAction = new NotificationCompat.Action.Builder(0, "Send Report", sendLogsPendingIntent).build();
NotificationCompat.Action action = new NotificationCompat.Action.Builder( R.drawable.ic_player_previous_light, mService.getString(R.string.playback_previous), mIntents.get(R.drawable.ic_player_previous_light)).build(); mNotificationBuilder.addAction(action); NotificationCompat.Action action = new NotificationCompat.Action.Builder( R.drawable.ic_player_next_light, mService.getString(R.string.playback_next), mIntents.get(R.drawable.ic_player_next_light)).build(); showInCompact.add(mNotificationBuilder.mActions.size()); mNotificationBuilder.addAction(action);
heartIntent.setAction(ScrobblingService.ACTION_HEART); PendingIntent heartPendingIntent = PendingIntent.getService(mCtx, 0, heartIntent, 0); NotificationCompat.Action heartAction = new NotificationCompat.Action.Builder(R.mipmap.ic_status_wail_love_track, "", heartPendingIntent).build();
new NotificationCompat.Action.Builder(R.drawable.ic_action_add, cxt.getString(R.string.add), pIntent) .addRemoteInput(remoteInput) .build();
new NotificationCompat.Action.Builder( R.drawable.ic_action_time, "Open Camera", cameraPendingIntent) .extend(inlineActionForWear2) .build();
new NotificationCompat.Action.Builder( android.R.drawable.ic_dialog_info, "Reply", resultPendingIntent) .addRemoteInput(remoteInput) .build();
heartIntent.setAction(ScrobblingService.ACTION_HEART); PendingIntent heartPendingIntent = PendingIntent.getService(mCtx, 0, heartIntent, 0); NotificationCompat.Action heartAction = new NotificationCompat.Action.Builder(R.mipmap.ic_status_wail_love_track, "", heartPendingIntent).build();
new NotificationCompat.Action.Builder(R.drawable.ic_action_time, "Open Camera", cameraPendingIntent) .build();
new NotificationCompat.Action.Builder(R.drawable.ic_full_poke, getString(R.string.texto_accion_toque), pendingIntent) .build();
NotificationCompat.Action action = new NotificationCompat.Action.Builder( R.drawable.ic_alarm_off_black_24dp, getResources().getString(R.string.mute_game), actionPendingIntent) .build();
new NotificationCompat.Action.Builder(R.drawable.ic_action_map, "Reply", replyPendingIntent) .addRemoteInput(remoteInput) .build();
private void goForeground() { if (mIsForeground) { return; } Intent stopIntent = new Intent(getApplicationContext(), UnboundService.class); stopIntent.setAction(ACTION_STOP); PendingIntent stopPendingIntent = PendingIntent .getService( getApplicationContext(), REQUEST_STOP, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT ); NotificationCompat.Action stopAction = new NotificationCompat.Action .Builder(android.R.drawable.ic_media_pause, getString(R.string.menu_stop), stopPendingIntent) .build(); Notification notification = new NotificationCompat.Builder(getApplicationContext()) .setContentTitle(getString(R.string.app_name)) .setSmallIcon(R.mipmap.ic_launcher) .setPriority(Notification.PRIORITY_MIN) .setCategory(NotificationCompat.CATEGORY_SERVICE) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setColor(Color.RED) .addAction(stopAction) .setWhen(System.currentTimeMillis()) .setVisibility(NotificationCompat.VISIBILITY_PRIVATE) .setOngoing(true) .build(); startForeground(NOTIFICATION_ID, notification); mIsForeground = true; }
yesReceiver.setAction(YES_ACTION); PendingIntent pendingIntentYes = PendingIntent.getBroadcast(context, 12345, yesReceiver, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action actionyes = new NotificationCompat.Action.Builder(R.drawable.yes, context.getString(R.string.yes), pendingIntentYes).build(); notification.addAction(actionyes); dismissReceiver.setAction(DISSMISS_ACTION); PendingIntent pendingIntentno = PendingIntent.getBroadcast(context, 12345, dismissReceiver, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action actionno = new NotificationCompat.Action.Builder(R.drawable.dismiss, context.getString(R.string.dismiss), pendingIntentno).build(); notification.addAction(actionno);
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); } }
private void listing11_25(Context context, NotificationCompat.Builder builder, Uri chatThreadUri) { // Listing 11-25: Adding a direct reply action // The key you'll use to later retrieve the reply final String KEY_TEXT_REPLY = "KEY_TEXT_REPLY"; Intent replyAction = new Intent(context, ReplyBroadcastReceiver.class); replyAction.setData(chatThreadUri); PendingIntent replyIntent = PendingIntent.getBroadcast(context, 0, replyAction, PendingIntent.FLAG_UPDATE_CURRENT); // Construct the RemoteInput RemoteInput remoteInput = new RemoteInput.Builder(KEY_TEXT_REPLY) .setLabel(context.getString(R.string.reply_hint_text)) .build(); builder.addAction( new NotificationCompat.Action.Builder( R.drawable.reply, context.getString(R.string.reply_action), replyIntent) .addRemoteInput(remoteInput) .setAllowGeneratedReplies(true) .extend(new NotificationCompat.Action.WearableExtender() .setHintDisplayActionInline(true)) .build()); }
private void updateFavoriteAction() { Log.d(TAG, "updateFavoriteAction"); String favoriteLabel; int favoriteIcon; RatingCompat rating = mMetadata.getRating(MediaMetadataCompat.METADATA_KEY_USER_RATING); if (rating != null && rating.hasHeart()) { favoriteLabel = mService.getString(R.string.playback_unfavorite); favoriteIcon = R.drawable.ic_action_favorites_small_underlined; } else { favoriteLabel = mService.getString(R.string.playback_favorite); favoriteIcon = R.drawable.ic_action_favorites_small; } if (mFavoriteAction == null) { mFavoriteAction = new NotificationCompat.Action.Builder(favoriteIcon, favoriteLabel, mIntents.get(favoriteIcon)).build(); } else { mFavoriteAction.icon = favoriteIcon; mFavoriteAction.title = favoriteLabel; mFavoriteAction.actionIntent = mIntents.get(favoriteIcon); } }