Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a count down timer in Notification's view?

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?)

like image 733
Michal Chudy Avatar asked Dec 06 '11 16:12

Michal Chudy


People also ask

How do I set a countdown clock on my Android?

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().

What is countdown interval in Android?

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.


1 Answers

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.

like image 158
kabuko Avatar answered Sep 18 '22 13:09

kabuko