I figured out how to make custom views using RemoteViews
class. I also know how to use Chronometer
and ProgressBar
inside of RemoteViews
.
But how to make a count down View
, almost exactly the same as Chronometer
but with the difference that it will be counting down instead of up?
I tried to copy the source of Chronometer
class and modify it so it will fit my needs, but there are annotations like @android.view.RemotableViewMethod
, which i can not import to my project. Unfortunately, without annotations it is not working, because RemoteViews
is using them to pass values.
My second idea was to extend the Chronometer
class and override proper methods, but they are private
.
Any ideas, is it possible? (And extra question, because I'm not sure: If the method is annotated and I override this method, is the annotation inherited?)
we can set count down time after completion of time it will stop and get 0 values. onTick(long millisUntilFinished ) - In this method we have to pass countdown mill seconds after done countdown it will stop Ticking. onFinish() - After finish ticking, if you want to call any methods or callbacks we can do in onFinish().
Android Countdown Timer Code In this example we've set a Timer for 10 seconds that updates after every second. By default the timer displays/updates the time in decreasing order ( as its named CountDown!), Hence to show the progress in increasing order we've subtracted the time from the max time.
I don't believe you're going to be able to use a custom class directly with RemoteViews
even if it's derived from one of the supported classes (annotations are not inherited). You could try using a TextView
, counting down in a Service
with a reference to the RemoteViews
object and updating from there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With