0

I want to override the android chronometer class. I want it to inflate a custom XML layout and to also have a quicker update interval.

I've found one that modifies the update interval from the default 1s to 0.1s on github.

But I want to do more and have imageViews or Buttons display the time instead of the default textView it uses. I haven't really done this before except for a recycle view, so some explanation would be nice.

My end goal is to have an efficient stopwatch with custom digits and display, like the one found on HTC one M7 in the default clock app or any Samsung phone. I also need it to run in its own Fragment and be able to handle orientation changes and the activities onPause() or onStop() without losing any time.

Would it be better to use Intent Service and a Results Reciever? if so how would i accomplish this?

nebuchadnezzar I
  • 125
  • 1
  • 12

1 Answers1

1

Chronometer is good for certain extent, but instead of customizing it you can create your own custom layout and display the time based on your requirements using a handler which would be the best solution for your problem.Find the link below for example

http://www.shawnbe.com/index.php/tutorial/tutorial-3-a-simple-stopwatch-lets-add-the-code/

Jayamurugan
  • 542
  • 2
  • 10
  • yes i have previously tried to use handlers. But it had problems with consistency and performance. – nebuchadnezzar I Nov 19 '16 at 09:16
  • my current implementaion involves scheduleExecutorService, and it works fine for the most part. I just cant get it to work on screen orientations or continue while the activity is paused or stopped – nebuchadnezzar I Nov 19 '16 at 09:17
  • For that you can save the starting time in preference, once the activity resumes assign the value of currentTime - startingTime to the chronometer and it continues. – Jayamurugan Nov 21 '16 at 05:23