I am making an Exercise app that is designed so the user uses it once per day. Say the current date is July 9, 2016... How would I go about setting the first event on the current date(July 9) and the second event on July (11) and so forth.
Asked
Active
Viewed 1,489 times
2 Answers
0
You can access dates using the Calendar class. to get the current date/time you can just do the following
Calendar cal = Calendar.getInstance();
if you wanted to get a different day you can do something like
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, 11);

Craig
- 364
- 1
- 3
- 25
0
You can use to the Calendar to get events in the following way -
Calendar calendar = Calendar.getInstance();
long today = Calendar.getTimeInMillis(); // July 9
calendar.add(Calendar.DAY_OF_MONTH, 2);
long day_after_tomorrow = Calendar.getTimeInMillis() // July 11
But, automatically events cannot be set like that in Calendar. It can only be used to get the time and date. If you want some sort of periodic notifications, check out -
- Alarm Manager
- Notification Manager
These have to be used in combination with Services and Broadcast Receivers. Check these out for reference: Alarm Manager Example, Sending a notification from a service in Android

therealanshuman
- 150
- 1
- 1
- 12