Java 类android.app.Notification.Action 实例源码

项目:NoticeDog    文件:Notification.java   
public Notification(Parcel in) {
    this.expandedInboxText = new ArrayList();
    this.people = new ArrayList();
    this.actions = new ArrayList();
    this.packageName = in.readString();
    this.id = in.readInt();
    this.tag = in.readString();
    this.key = in.readString();
    this.when = in.readLong();
    this.smallIcon = in.readInt();
    this.largeIcon = (Bitmap) in.readParcelable(Bitmap.class.getClassLoader());
    this.tickerText = in.readString();
    this.contentTitle = in.readString();
    this.contentText = in.readString();
    this.contentInfoText = in.readString();
    this.expandedLargeIconBig = (Bitmap) in.readParcelable(Bitmap.class.getClassLoader());
    this.expandedContentTitle = in.readString();
    this.expandedContentText = in.readString();
    in.readStringList(this.expandedInboxText);
    in.readList(this.people, Uri.class.getClassLoader());
    this.picture = (Bitmap) in.readParcelable(Bitmap.class.getClassLoader());
    this.priority = in.readInt();
    this.pendingLaunchIntent = (PendingIntent) in.readParcelable(PendingIntent.class.getClassLoader());
    in.readList(this.actions, Action.class.getClassLoader());
}
项目:FMTech    文件:efj.java   
public static void a(Notification.Builder paramBuilder, ea paramea)
{
  Notification.Action.Builder localBuilder = new Notification.Action.Builder(paramea.a(), paramea.b(), paramea.c());
  if (paramea.e() != null)
  {
    RemoteInput[] arrayOfRemoteInput = a(paramea.e());
    int i1 = arrayOfRemoteInput.length;
    for (int i2 = 0; i2 < i1; i2++) {
      localBuilder.addRemoteInput(arrayOfRemoteInput[i2]);
    }
  }
  if (paramea.d() != null) {
    localBuilder.addExtras(paramea.d());
  }
  paramBuilder.addAction(localBuilder.build());
}
项目:NoticeDog    文件:Notification.java   
@TargetApi(19)
public Notification(String packageName, int id, String tag, String key, android.app.Notification n) {
    this.packageName = packageName;
    this.id = id;
    this.tag = tag;
    this.key = key;
    this.when = n.when;
    this.smallIcon = n.extras.getInt(NotificationCompat.EXTRA_SMALL_ICON, 0);
    this.largeIcon = (Bitmap) n.extras.getParcelable(NotificationCompat.EXTRA_LARGE_ICON);
    if (n.tickerText != null) {
        this.tickerText = n.tickerText.toString();
    }
    this.contentTitle = getStringFromNotificationCharSequence(n, NotificationCompat.EXTRA_TITLE);
    this.contentText = getStringFromNotificationCharSequence(n, NotificationCompat.EXTRA_TEXT);
    this.contentInfoText = getStringFromNotificationCharSequence(n, NotificationCompat.EXTRA_INFO_TEXT);
    this.expandedLargeIconBig = (Bitmap) n.extras.getParcelable(NotificationCompat.EXTRA_LARGE_ICON_BIG);
    this.expandedContentTitle = getStringFromNotificationCharSequence(n, NotificationCompat.EXTRA_TITLE_BIG);
    this.expandedContentText = getStringFromNotificationCharSequence(n, NotificationCompat.EXTRA_SUMMARY_TEXT);
    this.expandedInboxText = getStringArrayFromNotificationCharSequenceArray(n, NotificationCompat.EXTRA_TEXT_LINES);
    this.people = getUriArrayFromNotificationParcelableArray(n, NotificationCompat.EXTRA_PEOPLE);
    this.picture = null;
    this.priority = n.priority;
    this.pendingLaunchIntent = n.contentIntent;
    this.actions = new ArrayList();
    if (n.actions != null) {
        for (Action a : n.actions) {
            String title = null;
            if (a.title != null) {
                title = a.title.toString();
            }
            this.actions.add(new Action(a.icon, title, a.actionIntent));
        }
    }
}
项目:FMTech    文件:efj.java   
public static Notification.Action a(ea paramea)
{
  Notification.Action.Builder localBuilder = new Notification.Action.Builder(paramea.a(), paramea.b(), paramea.c()).addExtras(paramea.d());
  ew[] arrayOfew = paramea.e();
  if (arrayOfew != null)
  {
    RemoteInput[] arrayOfRemoteInput = a(arrayOfew);
    int i1 = arrayOfRemoteInput.length;
    for (int i2 = 0; i2 < i1; i2++) {
      localBuilder.addRemoteInput(arrayOfRemoteInput[i2]);
    }
  }
  return localBuilder.build();
}
项目:gopro-remote    文件:WearNotificationManager.java   
private Notification.Builder newStreamNotification(CharSequence title, CharSequence text) {
    return new Notification.Builder(appContext)
            .setContentTitle(title)
            .setContentText(text)
            .setSmallIcon(R.mipmap.ic_launcher)
            .setLocalOnly(true)
            .setPriority(Notification.PRIORITY_MAX)
            .setVibrate(new long[]{0, 50}) // Vibrate to bring card to top of stream
            .setDeleteIntent(newLogPendingIntent("Delete intent triggered", PendingIntent.FLAG_CANCEL_CURRENT))
            .addAction(new Action(R.drawable.ic_fullscreen_white_48dp, "Fullscreen", newLaunchFullscreenPendingIntent()))
            .addAction(new Action(R.drawable.ic_network_wifi_white_48dp, "Connect to Wi-Fi", newConnectWifiPendingIntent()));
}
项目:gopro-remote    文件:WearNotificationManager.java   
private Notification.Builder newStatusNotification(CharSequence contentTitle, CharSequence contentText) {
    saveNotificationLabels(title, text);
    return new Notification.Builder(appContext)
            .setContentTitle(contentTitle)  // Current status and quick action icon
            .setContentText(contentText)
            .setSmallIcon(R.mipmap.ic_launcher)
            .setLocalOnly(true)
            .setPriority(Notification.PRIORITY_MAX)
            .setVibrate(new long[]{0, 50}) // Vibrate to bring card to top of stream
            .setDeleteIntent(newLogPendingIntent("Delete intent triggered", PendingIntent.FLAG_CANCEL_CURRENT))
            .extend(new Notification.WearableExtender()
                            .setBackground(BitmapFactory.decodeResource(appContext.getResources(), R.drawable.background))
                            .addPage(new Notification.Builder(appContext)
                                            .extend(new WearableExtender()
                                                            .setDisplayIntent(newControlPendingIntent()) // On, Off, Start, Stop
                                                            .setCustomSizePreset(WearableExtender.SIZE_FULL_SCREEN)
                                            )
                                            .build()
                            )
                            .addPage(new Notification.Builder(appContext)
                                            .extend(new WearableExtender()
                                                            .setDisplayIntent(newModePendingIntent()) // Mode wearable list view
                                                            .setCustomSizePreset(WearableExtender.SIZE_FULL_SCREEN)
                                            )
                                            .build()
                            )
                            .addAction(new Action(R.drawable.ic_network_wifi_white_48dp, "Connect to Wi-Fi", newConnectWifiPendingIntent()))
            );
}
项目:AndroidWearable-Samples    文件:FindPhoneActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Create a notification with an action to toggle an alarm on the phone.
    Intent toggleAlarmOperation = new Intent(this, FindPhoneService.class);
    toggleAlarmOperation.setAction(FindPhoneService.ACTION_TOGGLE_ALARM);
    PendingIntent toggleAlarmIntent = PendingIntent.getService(this, 0, toggleAlarmOperation,
            PendingIntent.FLAG_CANCEL_CURRENT);
    Action alarmAction = new Action(R.drawable.alarm_action_icon, "", toggleAlarmIntent);
    // This intent turns off the alarm if the user dismisses the card from the wearable.
    Intent cancelAlarmOperation = new Intent(this, FindPhoneService.class);
    cancelAlarmOperation.setAction(FindPhoneService.ACTION_CANCEL_ALARM);
    PendingIntent cancelAlarmIntent = PendingIntent.getService(this, 0, cancelAlarmOperation,
            PendingIntent.FLAG_CANCEL_CURRENT);
    // Use a spannable string for the notification title to resize it.
    SpannableString title = new SpannableString(getString(R.string.app_name));
    title.setSpan(new RelativeSizeSpan(0.85f), 0, title.length(), Spannable.SPAN_POINT_MARK);
    notification = new Notification.Builder(this)
            .setContentTitle(title)
            .setContentText(getString(R.string.turn_alarm_on))
            .setSmallIcon(R.drawable.ic_launcher)
            .setVibrate(new long[] {0, 50})  // Vibrate to bring card to top of stream.
            .setDeleteIntent(cancelAlarmIntent)
            .extend(new Notification.WearableExtender()
                    .addAction(alarmAction)
                    .setContentAction(0)
                    .setHintHideIcon(true))
            .setLocalOnly(true)
            .setPriority(Notification.PRIORITY_MAX);
    ((NotificationManager) getSystemService(NOTIFICATION_SERVICE))
            .notify(FIND_PHONE_NOTIFICATION_ID, notification.build());

    finish();
}
项目:NoticeDog    文件:Notification.java   
public List<Action> getActions() {
    return this.actions;
}
项目:AndroidWearable-Samples    文件:HomeListenerService.java   
/**
 * Posts a local notification for the given geofence id, with an option to check in.
 * @param geofenceId The geofence id that the user has triggered.
 * @param dataItemUri The Uri for the DataItem that triggered this notification. Used to delete
 *                    this DataItem when the notification is dismissed.
 */
private void postNotificationForGeofenceId(String geofenceId, Uri dataItemUri) {
    // Use the geofenceId to determine the title and background of the check-in notification.
    // A SpannableString is used for the notification title for resizing capabilities.
    SpannableString checkInTitle;
    Bitmap notificationBackground;
    if (ANDROID_BUILDING_ID.equals(geofenceId)) {
        checkInTitle = new SpannableString(getText(R.string.android_building_title));
        notificationBackground =
                BitmapFactory.decodeResource(getResources(), R.drawable.android_building);
    } else if (YERBA_BUENA_ID.equals(geofenceId)) {
        checkInTitle = new SpannableString(getText(R.string.yerba_buena_title));
        notificationBackground =
                BitmapFactory.decodeResource(getResources(), R.drawable.yerba_buena);
    } else {
        Log.e(TAG, "Unrecognized geofence id: " + geofenceId);
        return;
    }
    // Resize the title to avoid truncation.
    checkInTitle.setSpan(new RelativeSizeSpan(0.8f), 0, checkInTitle.length(),
            Spannable.SPAN_POINT_MARK);

    Intent checkInOperation =
            new Intent(this, CheckInAndDeleteDataItemsService.class).setData(dataItemUri);
    PendingIntent checkInIntent = PendingIntent.getService(this, 0,
            checkInOperation.setAction(ACTION_CHECK_IN), PendingIntent.FLAG_CANCEL_CURRENT);
    PendingIntent deleteDataItemIntent = PendingIntent.getService(this, 1,
            checkInOperation.setAction(ACTION_DELETE_DATA_ITEM),
            PendingIntent.FLAG_CANCEL_CURRENT);
    // This action will be embedded into the notification.
    Action checkInAction = new Action(R.drawable.ic_action_check_in,
            getText(R.string.check_in_prompt), checkInIntent);

    Notification notification = new Notification.Builder(this)
            .setContentTitle(checkInTitle)
            .setContentText(getText(R.string.check_in_prompt))
            .setSmallIcon(R.drawable.ic_launcher)
            .setDeleteIntent(deleteDataItemIntent)
            .extend(new Notification.WearableExtender()
                    .setBackground(notificationBackground)
                    .addAction(checkInAction)
                    .setContentAction(0)
                    .setHintHideIcon(true))
            .setLocalOnly(true)
            .build();

    ((NotificationManager) getSystemService(NOTIFICATION_SERVICE))
            .notify(NOTIFICATION_ID, notification);
}