当前位置: 首页>>代码示例>>Java>>正文


Java Action类代码示例

本文整理汇总了Java中android.support.v4.app.NotificationCompat.Action的典型用法代码示例。如果您正苦于以下问题:Java Action类的具体用法?Java Action怎么用?Java Action使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Action类属于android.support.v4.app.NotificationCompat包,在下文中一共展示了Action类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: matches

import android.support.v4.app.NotificationCompat.Action; //导入依赖的package包/类
@Override
public boolean matches(Object argument) {
    if (!(argument instanceof WearableExtender)) {
        return false;
    }

    WearableExtender wearableExtender = (WearableExtender) argument;
    for (Action action : wearableExtender.getActions()) {
        if (action.icon == icon && action.title.equals(title) && action.actionIntent == pendingIntent) {
            return true;
        }
    }

    return false;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:16,代码来源:WearNotificationsTest.java

示例2: buildWearableAction

import android.support.v4.app.NotificationCompat.Action; //导入依赖的package包/类
private Action buildWearableAction() {
    String replyLabel = mContext.getString(replyLabelResourceId);
    RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY).setLabel(replyLabel).build();
    // Create an intent for the reply action
    if (pendingIntent == null) {
        Intent replyIntent = new Intent(mContext, notificationHandler);
        pendingIntent = PendingIntent.getActivity(mContext, (int) (System.currentTimeMillis() & 0xfffffff), replyIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
    }
    // Create the reply action and add the remote input
    NotificationCompat.Action action = new NotificationCompat.Action.Builder(actionIconResId,
            mContext.getString(actionTitleId), pendingIntent).addRemoteInput(remoteInput).build();
    return action;
}
 
开发者ID:AppLozic,项目名称:Applozic-Android-Chat-Sample,代码行数:15,代码来源:WearableNotificationWithVoice.java

示例3: showHarmfulAppRemoveRequestMessage

import android.support.v4.app.NotificationCompat.Action; //导入依赖的package包/类
public final void showHarmfulAppRemoveRequestMessage(String paramString1, String paramString2, String paramString3, byte[] paramArrayOfByte, int paramInt)
{
  Intent localIntent1 = PackageWarningDialog.createIntent(this.mContext, PackageWarningDialog.NO_ID, 2, paramString1, paramString2, paramString3, paramArrayOfByte, paramInt);
  String str1 = this.mContext.getString(2131362833);
  String str2 = this.mContext.getString(2131362832, new Object[] { paramString1 });
  int i = this.mContext.getResources().getColor(2131689580);
  Intent localIntent2 = PackageVerificationService.createRemovalRequestIntent$6548352b(this.mContext, paramString2, paramArrayOfByte);
  PendingIntent localPendingIntent = PendingIntent.getService(this.mContext, 0, localIntent2, 268435456);
  NotificationCompat.Action localAction = new NotificationCompat.Action(2130837703, this.mContext.getString(2131362807), localPendingIntent);
  showNewNotification("package..remove..request..".concat(paramString2), str1, str1, str2, str2, 2130837900, null, -1, localIntent1, false, null, true, "status", null, null, i, 2, localAction);
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:12,代码来源:NotificationManager.java

示例4: showActionButtonsNotification

import android.support.v4.app.NotificationCompat.Action; //导入依赖的package包/类
private void showActionButtonsNotification() {
  Intent yesIntent = getNotificationIntent();
  yesIntent.setAction(YES_ACTION);

  Intent maybeIntent = getNotificationIntent();
  maybeIntent.setAction(MAYBE_ACTION);

  Intent noIntent = getNotificationIntent();
  noIntent.setAction(NO_ACTION);

  Notification notification = new NotificationCompat.Builder(this)
      .setContentIntent(PendingIntent.getActivity(this, 0, getNotificationIntent(), PendingIntent.FLAG_UPDATE_CURRENT))
      .setSmallIcon(R.mipmap.ic_launcher)
      .setTicker("Action Buttons Notification Received")
      .setContentTitle("Hi there!")
      .setContentText("This is even more text.")
      .setWhen(System.currentTimeMillis())
      .setAutoCancel(true)
      .addAction(new Action(
          R.mipmap.ic_thumb_up_black_36dp,
          getString(R.string.yes),
          PendingIntent.getActivity(this, 0, yesIntent, PendingIntent.FLAG_UPDATE_CURRENT)))
      .addAction(new Action(
          R.mipmap.ic_thumbs_up_down_black_36dp,
          getString(R.string.maybe),
          PendingIntent.getActivity(this, 0, maybeIntent, PendingIntent.FLAG_UPDATE_CURRENT)))
      .addAction(new Action(
          R.mipmap.ic_thumb_down_black_36dp,
          getString(R.string.no),
          PendingIntent.getActivity(this, 0, noIntent, PendingIntent.FLAG_UPDATE_CURRENT)))
      .build();

  notificationManager.notify(NOTIFY_ID, notification);
}
 
开发者ID:rylexr,项目名称:android-simple-notification-app,代码行数:35,代码来源:SimpleNotificationActivity.java

示例5: notification_createActionButton

import android.support.v4.app.NotificationCompat.Action; //导入依赖的package包/类
notification_createActionButton(Context context,
		NOTIFICATION_ACTION_TARGET_TYPE targetType,
		String actionKey,				
		Class<?> targetClazz, 
		String notificationIdKey, int notificationId,
		int iconId, String title, Bundle extras) {
	
	Intent i = new Intent(context, targetClazz);
	i.setAction(actionKey);
	i.putExtra(notificationIdKey, notificationId);
	
	if(extras!=null){
		i.putExtras(extras);
	}
	
	PendingIntent pIntent = null;
	if(targetType==null) {
		pIntent = PendingIntent.getBroadcast(context, ToolBox.random_getRandom().nextInt(), i, PendingIntent.FLAG_UPDATE_CURRENT);
	}else{
		switch (targetType) {
			case ACTIVITY:
				pIntent = PendingIntent.getActivity(context, ToolBox.random_getRandom().nextInt(), i, PendingIntent.FLAG_UPDATE_CURRENT);
				break;
			case RECEIVER:
				pIntent = PendingIntent.getBroadcast(context, ToolBox.random_getRandom().nextInt(), i, PendingIntent.FLAG_UPDATE_CURRENT);
				break;
			case SERVICE:
				pIntent = PendingIntent.getService(context, ToolBox.random_getRandom().nextInt(), i, PendingIntent.FLAG_UPDATE_CURRENT);
				break;
			default:
				pIntent = PendingIntent.getBroadcast(context, ToolBox.random_getRandom().nextInt(), i, PendingIntent.FLAG_UPDATE_CURRENT);
				break;
		}
	}
	
	android.support.v4.app.NotificationCompat.Action action = 
   			new android.support.v4.app.NotificationCompat.Action(iconId, title, pIntent);
	
	return action;
}
 
开发者ID:javocsoft,项目名称:javocsoft-toolbox,代码行数:41,代码来源:ToolBox.java

示例6: addActions

import android.support.v4.app.NotificationCompat.Action; //导入依赖的package包/类
public void addActions(@Nullable MasterSecret masterSecret,
                       @NonNull PendingIntent markReadIntent,
                       @NonNull PendingIntent quickReplyIntent,
                       @NonNull PendingIntent wearableReplyIntent)
{
  Action markAsReadAction = new Action(R.drawable.check,
                                       context.getString(R.string.MessageNotifier_mark_read),
                                       markReadIntent);

  if (masterSecret != null) {
    Action replyAction = new Action(R.drawable.ic_reply_white_36dp,
                                    context.getString(R.string.MessageNotifier_reply),
                                    quickReplyIntent);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
      replyAction = new Action.Builder(R.drawable.ic_reply_white_36dp,
                                       context.getString(R.string.MessageNotifier_reply),
                                       wearableReplyIntent)
          .addRemoteInput(new RemoteInput.Builder(MessageNotifier.EXTRA_REMOTE_REPLY)
                              .setLabel(context.getString(R.string.MessageNotifier_reply)).build())
          .build();
    }

    Action wearableReplyAction = new Action.Builder(R.drawable.ic_reply,
                                                    context.getString(R.string.MessageNotifier_reply),
                                                    wearableReplyIntent)
        .addRemoteInput(new RemoteInput.Builder(MessageNotifier.EXTRA_REMOTE_REPLY)
                            .setLabel(context.getString(R.string.MessageNotifier_reply)).build())
        .build();

    addAction(markAsReadAction);
    addAction(replyAction);

    extend(new NotificationCompat.WearableExtender().addAction(markAsReadAction)
                                                    .addAction(wearableReplyAction));
  } else {
    addAction(markAsReadAction);

    extend(new NotificationCompat.WearableExtender().addAction(markAsReadAction));
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:42,代码来源:SingleRecipientNotificationBuilder.java

示例7: showNewNotification

import android.support.v4.app.NotificationCompat.Action; //导入依赖的package包/类
private void showNewNotification(final String paramString1, String paramString2, final String paramString3, final String paramString4, String paramString5, int paramInt1, Bitmap paramBitmap, int paramInt2, final Intent paramIntent1, boolean paramBoolean1, Intent paramIntent2, boolean paramBoolean2, String paramString6, Intent paramIntent3, String paramString7, int paramInt3, int paramInt4, NotificationCompat.Action paramAction)
{
  final NotificationCompat.Builder localBuilder = new NotificationCompat.Builder(this.mContext).setTicker(paramString2).setContentTitle(paramString3).setContentText(paramString4);
  localBuilder.mCategory = paramString6;
  localBuilder.mVisibility = 0;
  localBuilder.mLocalOnly = true;
  if (!TextUtils.isEmpty(paramString5)) {
    localBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(paramString5));
  }
  localBuilder.setSmallIcon(paramInt1);
  if (paramBitmap != null) {
    localBuilder.mLargeIcon = paramBitmap;
  }
  if (paramInt2 > 0) {
    localBuilder.mNumber = paramInt2;
  }
  localBuilder.mColor = paramInt3;
  localBuilder.mPriority = paramInt4;
  if (paramAction != null) {
    localBuilder.mActions.add(paramAction);
  }
  final int i = getNotificationId(paramString1);
  PendingIntent localPendingIntent1;
  if (!paramBoolean1)
  {
    localPendingIntent1 = PendingIntent.getActivity(this.mContext, i, paramIntent1, 1342177280);
    localBuilder.mContentIntent = localPendingIntent1;
    if (paramIntent2 != null)
    {
      PendingIntent localPendingIntent3 = PendingIntent.getBroadcast(this.mContext, i, paramIntent2, 1342177280);
      localBuilder.mNotification.deleteIntent = localPendingIntent3;
    }
    if ((paramIntent3 != null) && (!TextUtils.isEmpty(paramString7)))
    {
      PendingIntent localPendingIntent2 = PendingIntent.getBroadcast(this.mContext, i, paramIntent3, 1342177280);
      localBuilder.mActions.add(new NotificationCompat.Action(2130838134, paramString7, localPendingIntent2));
    }
    if (!paramBoolean2) {
      break label316;
    }
    localBuilder.setFlag(2, true);
  }
  for (;;)
  {
    RestrictedDeviceHelper.isLimitedOrSchoolEduUser(new RestrictedDeviceHelper.OnCompleteListener()
    {
      public final void onComplete(boolean paramAnonymousBoolean)
      {
        if (!paramAnonymousBoolean) {
          this.val$mgr.notify(i, localBuilder.build());
        }
        if (!paramAnonymousBoolean) {}
        for (boolean bool = true;; bool = false)
        {
          NotificationManager.access$100(bool, paramString1, paramString3, paramString4, paramIntent1);
          return;
        }
      }
    });
    return;
    localPendingIntent1 = PendingIntent.getBroadcast(this.mContext, i, paramIntent1, 1342177280);
    break;
    label316:
    localBuilder.setAutoCancel$7abcb88d();
  }
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:67,代码来源:NotificationManager.java

示例8: sendSingleThreadNotification

import android.support.v4.app.NotificationCompat.Action; //导入依赖的package包/类
private static void sendSingleThreadNotification(Context context,
                                                 MasterSecret masterSecret,
                                                 NotificationState notificationState,
                                                 boolean signal)
{
  if (notificationState.getNotifications().isEmpty()) {
    ((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE))
        .cancel(NOTIFICATION_ID);
    return;
  }

  List<NotificationItem>     notifications       = notificationState.getNotifications();
  NotificationCompat.Builder builder             = new NotificationCompat.Builder(context);
  Recipient                  recipient           = notifications.get(0).getIndividualRecipient();
  Drawable                   recipientPhoto      = recipient.getContactPhoto();
  int                        largeIconTargetSize = context.getResources().getDimensionPixelSize(R.dimen.contact_photo_target_size);

  if (recipientPhoto != null) {
    Bitmap recipientPhotoBitmap = BitmapUtil.createFromDrawable(recipientPhoto, largeIconTargetSize, largeIconTargetSize);
    if (recipientPhotoBitmap != null) builder.setLargeIcon(recipientPhotoBitmap);
  }

  builder.setSmallIcon(R.drawable.icon_notification);
  builder.setColor(context.getResources().getColor(R.color.textsecure_primary));
  builder.setContentTitle(recipient.toShortString());
  builder.setContentText(notifications.get(0).getText());
  builder.setContentIntent(notifications.get(0).getPendingIntent(context));
  builder.setContentInfo(String.valueOf(notificationState.getMessageCount()));
  builder.setPriority(NotificationCompat.PRIORITY_HIGH);
  builder.setNumber(notificationState.getMessageCount());
  builder.setCategory(NotificationCompat.CATEGORY_MESSAGE);
  builder.setDeleteIntent(PendingIntent.getBroadcast(context, 0, new Intent(DeleteReceiver.DELETE_REMINDER_ACTION), 0));
  if (recipient.getContactUri() != null) builder.addPerson(recipient.getContactUri().toString());

  long timestamp = notifications.get(0).getTimestamp();
  if (timestamp != 0) builder.setWhen(timestamp);

  if (masterSecret != null) {
    Action markAsReadAction = new Action(R.drawable.check,
                                         context.getString(R.string.MessageNotifier_mark_as_read),
                                         notificationState.getMarkAsReadIntent(context, masterSecret));
    builder.addAction(markAsReadAction);
    builder.extend(new NotificationCompat.WearableExtender().addAction(markAsReadAction));
  }

  SpannableStringBuilder content = new SpannableStringBuilder();

  ListIterator<NotificationItem> iterator = notifications.listIterator(notifications.size());
  while(iterator.hasPrevious()) {
    NotificationItem item = iterator.previous();
    content.append(item.getBigStyleSummary());
    content.append('\n');
  }

  builder.setStyle(new BigTextStyle().bigText(content));

  setNotificationAlarms(context, builder, signal,
                        notificationState.getRingtone(),
                        notificationState.getVibrate());

  if (signal) {
    builder.setTicker(notifications.get(0).getTickerText());
  }

  ((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE))
    .notify(NOTIFICATION_ID, builder.build());
}
 
开发者ID:Agilitum,项目名称:TextSecureSMP,代码行数:68,代码来源:MessageNotifier.java

示例9: sendMultipleThreadNotification

import android.support.v4.app.NotificationCompat.Action; //导入依赖的package包/类
private static void sendMultipleThreadNotification(Context context,
                                                   MasterSecret masterSecret,
                                                   NotificationState notificationState,
                                                   boolean signal)
{
  List<NotificationItem> notifications = notificationState.getNotifications();
  NotificationCompat.Builder builder   = new NotificationCompat.Builder(context);

  builder.setColor(context.getResources().getColor(R.color.textsecure_primary));
  builder.setSmallIcon(R.drawable.icon_notification);
  builder.setContentTitle(context.getString(R.string.app_name));
  builder.setSubText(context.getString(R.string.MessageNotifier_d_messages_in_d_conversations,
                                       notificationState.getMessageCount(),
                                       notificationState.getThreadCount()));
  builder.setContentText(context.getString(R.string.MessageNotifier_most_recent_from_s,
                                           notifications.get(0).getIndividualRecipientName()));
  builder.setContentIntent(PendingIntent.getActivity(context, 0, new Intent(context, ConversationListActivity.class), 0));
  
  builder.setContentInfo(String.valueOf(notificationState.getMessageCount()));
  builder.setNumber(notificationState.getMessageCount());
  builder.setCategory(NotificationCompat.CATEGORY_MESSAGE);

  long timestamp = notifications.get(0).getTimestamp();
  if (timestamp != 0) builder.setWhen(timestamp);

  builder.setDeleteIntent(PendingIntent.getBroadcast(context, 0, new Intent(DeleteReceiver.DELETE_REMINDER_ACTION), 0));

  if (masterSecret != null) {
     Action markAllAsReadAction = new Action(R.drawable.check,
                                             context.getString(R.string.MessageNotifier_mark_all_as_read),
                                             notificationState.getMarkAsReadIntent(context, masterSecret));
     builder.addAction(markAllAsReadAction);
     builder.extend(new NotificationCompat.WearableExtender().addAction(markAllAsReadAction));
  }

  InboxStyle style = new InboxStyle();

  ListIterator<NotificationItem> iterator = notifications.listIterator(notifications.size());
  while(iterator.hasPrevious()) {
    NotificationItem item = iterator.previous();
    style.addLine(item.getTickerText());
    if (item.getIndividualRecipient().getContactUri() != null) {
      builder.addPerson(item.getIndividualRecipient().getContactUri().toString());
    }
  }

  builder.setStyle(style);

  setNotificationAlarms(context, builder, signal,
                        notificationState.getRingtone(),
                        notificationState.getVibrate());

  if (signal) {
    builder.setTicker(notifications.get(0).getTickerText());
  }

  ((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE))
    .notify(NOTIFICATION_ID, builder.build());
}
 
开发者ID:Agilitum,项目名称:TextSecureSMP,代码行数:60,代码来源:MessageNotifier.java

示例10: getCompleteAction

import android.support.v4.app.NotificationCompat.Action; //导入依赖的package包/类
public static Action getCompleteAction(Context context, PendingIntent intent)
{
    return new Action(R.drawable.ic_action_complete, context.getString(R.string.notification_action_complete), intent);
}
 
开发者ID:dmfs,项目名称:opentasks,代码行数:5,代码来源:NotificationUpdaterService.java

示例11: getUnpinAction

import android.support.v4.app.NotificationCompat.Action; //导入依赖的package包/类
public static Action getUnpinAction(Context context, PendingIntent intent)
{
    return new Action(R.drawable.ic_action_complete, context.getString(R.string.notification_action_complete), intent);
}
 
开发者ID:dmfs,项目名称:opentasks,代码行数:5,代码来源:NotificationUpdaterService.java

示例12: getDelay1hAction

import android.support.v4.app.NotificationCompat.Action; //导入依赖的package包/类
public static Action getDelay1hAction(Context context, int notificationId, Uri taskUri, long due, String timezone)
{
    return new Action(R.drawable.ic_detail_delay_1h_inverse, context.getString(R.string.notification_action_delay_1h), getDelayActionIntent(context,
            notificationId, taskUri, due, true, timezone, false));
}
 
开发者ID:dmfs,项目名称:opentasks,代码行数:6,代码来源:NotificationUpdaterService.java

示例13: getDelay1dAction

import android.support.v4.app.NotificationCompat.Action; //导入依赖的package包/类
public static Action getDelay1dAction(Context context, int notificationId, Uri taskUri, long due, String timezone, boolean allday)
{
    return new Action(R.drawable.ic_detail_delay_1d_inverse, context.getString(R.string.notification_action_delay_1d), getDelayActionIntent(context,
            notificationId, taskUri, due, false, timezone, allday));
}
 
开发者ID:dmfs,项目名称:opentasks,代码行数:6,代码来源:NotificationUpdaterService.java

示例14: Action

import android.support.v4.app.NotificationCompat.Action; //导入依赖的package包/类
/**
 * Creates an action for a notification. Only for Android 4.1 (API level 16+)
 * <br><br>
 * The generated Action also has a field {@link ToolBox#NOTIFICATION_ID} in its extra
 * Bundle for afterwards being able to cancel the parent notification once the
 * action is consumed.<br><br>
 * 
 * See also {@link ToolBox#notification_createActionButton}
 * 
 * @param iconId			The icon resource id for the action.
 * @param title				The title.
 * @param actionIntent		The pending intent of the action.
 * @param notificationId	Used to be able to cancel a notification once
 * 							the action is consumed.
 * @return
 * @Deprecated Use {@link ToolBox#notification_createActionButton}
 */
public static android.support.v4.app.NotificationCompat.Action 
	notification_createAction(int iconId, String title, PendingIntent actionIntent, 
			int notificationId) {
	
	Action action = new Action(iconId, title, actionIntent);
	action.getExtras().putInt(NOTIFICATION_ID, notificationId);
	
	return action;
}
 
开发者ID:javocsoft,项目名称:javocsoft-toolbox,代码行数:27,代码来源:ToolBox.java


注:本文中的android.support.v4.app.NotificationCompat.Action类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。