示例#1
0
  @Override
  protected void onHandleIntent(Intent intent) {
    if (builder == null) {
      cancellUpdate();
      return;
    }
    long progress = Math.min(duration, System.currentTimeMillis() - start);
    Notification notification = builder.setProgress((int) duration, (int) progress, false).build();
    if (progress == duration) {
      cancellUpdate();
    }

    NotificationManager notificationManager =
        (NotificationManager)
            getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);

    notification.flags |= Notification.FLAG_NO_CLEAR;
    notificationManager.notify(TaskService.CURRENT_TASK_NOTIFICATION_ID, notification);
  }