public void onEvent(PlayerState playerState) {
    mPlayerState = playerState;
    updateNotification();

    if (playerState.streamingState == PlayerState.StreamingState.STOPPED) {
      mService.stopForeground(false);
    } else {
      mService.startForeground(BalataNotifier.NOTIFY_ID, createNotification());
    }
  }
Пример #2
0
  public void moveToForeground(int id, Notification notification, boolean cancelNotification) {
    if (!this.foreground && notification != null) {
      this.foreground = true;
      this.id = id;
      this.cancelNotification = cancelNotification;

      super.startForeground(id, notification);
    } else if (this.id != id && id > 0 && notification != null) {
      this.id = id;
      ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).notify(id, notification);
    }
  }
  public static void startForegroundNotification(
      Context context,
      int notificationId,
      RemoteViews view,
      Intent intent,
      PendingIntent pendingIntent,
      int iconR,
      String str) {

    Notification notification =
        NotificationUtils.creatResidentNotification(
            context, notificationId, iconR, intent, view, "", Notification.FLAG_ONGOING_EVENT);

    ((Service) context).startForeground(notificationId, notification);
  }
Пример #4
0
 private static void startOnForeground(Service service, boolean playSound) {
   service.startForeground(
       STICKY_NOTIFICATION_ID,
       buildNotification(service.getApplicationContext(), playSound, null));
 }