PDA

View Full Version : Programming a Clock + Schedule App from System Time



kerblaster
08-04-2012, 12:08 PM
Hi, I was wondering what android method I should use to import the system time into like a variable that I can test.
For example, I want to make an app where when the app reads the system time to be 12:00-12:30, it will say "Lunch time" If its 12:30-1, it will say "Gym" or something a long those lines. Any suggestions?

Tramontana
08-07-2012, 02:04 PM
Use new GregorianCalendar() to create a Calendar for the current time. This has a get(field) method where field is one of a large number of constants for the hour, minute, day, month etc. Then use some logic to decide which name you want to give for that part of the day. All the documentation is online at Calendar (http://developer.android.com/reference/java/util/Calendar.html) and GregorianCalendar (http://developer.android.com/reference/java/util/GregorianCalendar.html). I can't be more specific as your question is a little imprecise.