comparing input Date & Time with current date & time in android -
i creating "to-do things" app user can create tasks done. in main activity have fragment consists of 3 edittexts ie notification content , date & time of notification.
each new entry added database. database displayed in form of listview in activity.
my questions are-:
q1) want compare date & time of each entry & print come ie date & time after present date & time.so how should perform comparison?
q2) when date & time reached generate notification .
q1) use calendar class. can take calendar object , set date , time user data (using calendar.set) , compare calendar set current time follows:
calendar cal = gregoriancalendar.getinstance(); cal.settimeinmillis(system.currenttimemillis());
to compare 2 calendars can use calendar.before method, or can convert them "timeinmillis" , calculate difference in milliseconds.
q2) use thealarmmanager , broadcastreceiver
Comments
Post a Comment