コード例 #1
0
ファイル: MVVCard.java プロジェクト: g0ne/TumCampusApp
  @Override
  protected Notification fillNotification(NotificationCompat.Builder notificationBuilder) {
    NotificationCompat.WearableExtender morePageNotification =
        new NotificationCompat.WearableExtender();

    String firstContent = "", firstTime = "";
    for (TransportManager.Departure d : mDepartures) {
      if (firstTime.isEmpty()) {
        firstTime = d.countDown + "min";
        firstContent = d.servingLine;
      }

      NotificationCompat.Builder pageNotification =
          new NotificationCompat.Builder(mContext)
              .setContentTitle(d.countDown + "min")
              .setContentText(d.servingLine);
      morePageNotification.addPage(pageNotification.build());
    }

    notificationBuilder.setContentTitle(firstTime);
    notificationBuilder.setContentText(firstContent);
    Bitmap bm = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.wear_mvv);
    morePageNotification.setBackground(bm);
    return morePageNotification.extend(notificationBuilder).build();
  }
コード例 #2
0
  @NonNull
  public Notification buildNotificationWear(@NonNull Intent displayIntent) {

    final NotificationCompat.WearableExtender extender =
        new NotificationCompat.WearableExtender()
            .setBackground(getBackground())
            .setHintHideIcon(true);
    if (pomodoroMaster.isOngoing()) {
      final PendingIntent displayPendingIntent =
          PendingIntent.getActivity(
              context, ID_ACTIVITY, displayIntent, PendingIntent.FLAG_UPDATE_CURRENT);
      extender.setDisplayIntent(displayPendingIntent);
    } else {
      extender.setContentIcon(R.drawable.ic_action_start_grey);
    }

    NotificationCompat.Builder builder =
        buildBaseNotification(/* isPhone */ false)
            .addAction(buildResetAction(context))
            .extend(extender);

    return builder.build();
  }