android - Show "left time" until the alarm start -


i whould create alarm (alarmmanager) in android. alarm must show left time until finish.

so user click on "set alarm @ 11 pm" , see in textview "alarm in xy hours/minuts/seconds".

how can achieve this?

thanks.

try

    calendar calendar = calendar.getinstance();     long pretime = calendar.gettimeinmillis();      // set alarm after 5 minute      calendar.add(calendar.minute, 5);     long posttime = calendar.gettimeinmillis();     long delay = posttime - pretime;      alarmmanager manager = (alarmmanager)     getsystemservice(context.alarm_service);     manager.set(alarmmanager.rtc_wakeup, posttime, null);      countdowntimer timer = new countdowntimer(delay, 1) {          @override         public void ontick(long millisuntilfinished) {             final int seconds = (int) (millisuntilfinished / 1000) % 60;             final int minutes = (int) ((millisuntilfinished / (1000 * 60)) % 60);              runonuithread(new runnable() {                  @override                 public void run() {                     text.settext("minute " + minutes + " second " + seconds);                 }             });         }          @override         public void onfinish() {             // todo auto-generated method stub          }     };     timer.start(); 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -