0

I have a notification build with chronometer enabled. I also have notification actions which pauses and resumes my task along with the chronometer obviously. But I cannot make the chronometer pickup from the earlier elapsed time. My time calculation is as below.

private void pauseTask(){
    updateNotification(createNotification(action).setUsesChronometer(false).build(), Config.NOTIFICATION_ID);
    elapsedTime = System.currentTimeMillis() + (System.currentTimeMillis() - startTime);
    //perform pause operation here
}

private void resumeTask(){
    startTime = System.currentTimeMillis();
    long time = System.currentTimeMillis() - (startTime - elapsedTime);
    updateNotification(createNotification(action)
            .setWhen(time)
            .build(), Config.NOTIFICATION_ID);
    //Perform pause task
}

The startTime in pauseTask is time obtained when the action was started fresh

Vijai
  • 1,067
  • 2
  • 11
  • 25

1 Answers1

0

I am having the same problem, and the only solution i can think of is to create a new instance of the builder to reset setUsesChronometer

         mBuilder = new NotificationCompat.Builder(this);
AdF
  • 3
  • 2