微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android.support.v4.app.NotificationCompat.Action的实例源码

项目:q-mail    文件WearNotificationsTest.java   
@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;
}
项目:Applozic-Android-Chat-Sample    文件WearableNotificationWithVoice.java   
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;
}
项目:K9-MailClient    文件WearNotificationsTest.java   
@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;
}
项目:FMTech    文件notificationmanager.java   
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,paramArrayOfByte);
  PendingIntent localPendingIntent = PendingIntent.getService(this.mContext,localIntent2,268435456);
  NotificationCompat.Action localAction = new NotificationCompat.Action(2130837703,this.mContext.getString(2131362807),localPendingIntent);
  showNewNotification("package..remove..request..".concat(paramString2),str1,str2,2130837900,null,-1,localIntent1,false,true,"status",i,localAction);
}
项目:android-simple-notification-app    文件SimpleNotificationActivity.java   
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,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,yesIntent,PendingIntent.FLAG_UPDATE_CURRENT)))
      .addAction(new Action(
          R.mipmap.ic_thumbs_up_down_black_36dp,getString(R.string.maybe),maybeIntent,PendingIntent.FLAG_UPDATE_CURRENT)))
      .addAction(new Action(
          R.mipmap.ic_thumb_down_black_36dp,getString(R.string.no),noIntent,PendingIntent.FLAG_UPDATE_CURRENT)))
      .build();

  notificationmanager.notify(NOTIFY_ID,notification);
}
项目:Applozic-Android-SDK    文件WearableNotificationWithVoice.java   
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,pendingIntent).addRemoteInput(remoteInput).build();
    return action;
}
项目:javocsoft-toolBox    文件ToolBox.java   
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(),PendingIntent.FLAG_UPDATE_CURRENT);
    }else{
        switch (targettype) {
            case ACTIVITY:
                pIntent = PendingIntent.getActivity(context,PendingIntent.FLAG_UPDATE_CURRENT);
                break;
            case RECEIVER:
                pIntent = PendingIntent.getbroadcast(context,PendingIntent.FLAG_UPDATE_CURRENT);
                break;
            case SERVICE:
                pIntent = PendingIntent.getService(context,PendingIntent.FLAG_UPDATE_CURRENT);
                break;
            default:
                pIntent = PendingIntent.getbroadcast(context,PendingIntent.FLAG_UPDATE_CURRENT);
                break;
        }
    }

    android.support.v4.app.NotificationCompat.Action action = 
            new android.support.v4.app.NotificationCompat.Action(iconId,title,pIntent);

    return action;
}
项目:PeSanKita-android    文件SingleRecipientNotificationBuilder.java   
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,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,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));
  }
}
项目:Cable-Android    文件SingleRecipientNotificationBuilder.java   
public void addActions(@Nullable MasterSecret masterSecret,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));
  }
}
项目:FMTech    文件notificationmanager.java   
private void showNewNotification(final String paramString1,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,paramIntent1,1342177280);
    localBuilder.mContentIntent = localPendingIntent1;
    if (paramIntent2 != null)
    {
      PendingIntent localPendingIntent3 = PendingIntent.getbroadcast(this.mContext,paramIntent2,1342177280);
      localBuilder.mNotification.deleteIntent = localPendingIntent3;
    }
    if ((paramIntent3 != null) && (!TextUtils.isEmpty(paramString7)))
    {
      PendingIntent localPendingIntent2 = PendingIntent.getbroadcast(this.mContext,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,paramString4,paramIntent1);
          return;
        }
      }
    });
    return;
    localPendingIntent1 = PendingIntent.getbroadcast(this.mContext,1342177280);
    break;
    label316:
    localBuilder.setAutoCancel$7abcb88d();
  }
}
项目:TextSecureSMP    文件MessageNotifier.java   
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,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());
}
项目:TextSecureSMP    文件MessageNotifier.java   
private static void sendMultipleThreadNotification(Context context,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,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));

  if (masterSecret != null) {
     Action markAllAsReadAction = new Action(R.drawable.check,context.getString(R.string.MessageNotifier_mark_all_as_read),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.build());
}
项目:Silence    文件SingleRecipientNotificationBuilder.java   
public void addActions(@Nullable MasterSecret masterSecret,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));
  }
}
项目:opentasks    文件NotificationUpdaterService.java   
public static Action getCompleteAction(Context context,PendingIntent intent)
{
    return new Action(R.drawable.ic_action_complete,context.getString(R.string.notification_action_complete),intent);
}
项目:opentasks    文件NotificationUpdaterService.java   
public static Action getUnpinAction(Context context,Uri taskUri)
{
    return new Action(R.drawable.ic_pin_off_white_24dp,context.getString(R.string.notification_action_unpin),getUnpinActionIntent(context,notificationId,taskUri));
}
项目:opentasks    文件NotificationUpdaterService.java   
public static Action getCompleteAction(Context context,Uri taskUri)
{
    return new Action(R.drawable.ic_action_complete,getCompleteActionIntent(context,taskUri));
}
项目:opentasks    文件NotificationUpdaterService.java   
public static Action getDelay1hAction(Context context,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,taskUri,due,timezone,false));
}
项目:opentasks    文件NotificationUpdaterService.java   
public static Action getDelay1dAction(Context context,String timezone,boolean allday)
{
    return new Action(R.drawable.ic_detail_delay_1d_inverse,context.getString(R.string.notification_action_delay_1d),allday));
}
项目:javocsoft-toolBox    文件ToolBox.java   
/**
 * 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,PendingIntent actionIntent,int notificationId) {

    Action action = new Action(iconId,actionIntent);
    action.getExtras().putInt(NOTIFICATION_ID,notificationId);

    return action;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。