calendar - How to set an Alarm in an Android App based on a server's current time? -


i building android application sets alarm based on application's server time.

by comparing gmt , application server time trying create alarm.

for example: gmt = 10.30 , server time = 4.30 am, need set alarm after 1hour/2hour server time.

example code:

calendar calender=calendar.getinstance(timezone.gettimezone("gmt")); calender.set(calendar.hour,-6); // server running time less 6 hours of gmt time. calender.set(calendar.minute,0); calender.set(calendar.second,0); 

can has idea on how set alarm
how set alarm?

from understand, here need do.

  1. get calendar object gmt timezone.
  2. get current time.
  3. set current time calendar object.
  4. finally, add 1 hour calendar object.

here how can achieve this:

calendar calendar = calendar.getinstance(timezone.gettimezone("gmt")); long currenttime = system.currenttimemillis(); calendar.settimeinmillis(currenttime); calendar.add(calendar.hour, 1); 

hope helps!


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -