0

i developed a app something like appointment where user will enter some details along with date and time he wants. Then i want to display that appointment details in calendar for particular date and time that was selected by user.

i have used following link to add event to calendar. here

In this i am adding all my details to ContentValues using put().Through this code i am able to add event to current date only since i am adding cal.getTimeInMillis().

how can add my appointment to particular date? can anybody solve my issue? please help me, thanks in advance.

Community
  • 1
  • 1
Abhi
  • 8,935
  • 7
  • 37
  • 60

1 Answers1

1

you can set event to particular time by adding time in milliseconds. Example use cal.getTimeInMillis()+60*60*1000 instaed of cal.getTimeInMillis() to get any particular date

Example

Calendar cal = Calendar.getInstance();              
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("beginTime", cal.getTimeInMillis()+60*60*1000);
intent.putExtra("allDay", true);
intent.putExtra("rrule", "FREQ=YEARLY");
intent.putExtra("endTime", cal.getTimeInMillis()+60*60*1000);
intent.putExtra("title", "A Test Event from android app");
startActivity(intent);
Sunil Kumar Sahoo
  • 53,011
  • 55
  • 178
  • 243
  • Thank you for your reply, but user will dynamically take his date, but how can we measure that date using cal.getTimeMillis()+60*60*1000. – Abhi Jun 30 '11 at 06:04
  • you can get the date difference betwen user selected date and current date – Sunil Kumar Sahoo Jun 30 '11 at 06:13
  • thank you for response,to make my thought clear once again i am telling, (User will select particular date in date picker, for that date event should be added, cal.getTimeInMillis+60*60*1000 using how can we get user date? for suppose his date is 07/01/2011 mm/dd/yyyy format. – Abhi Jun 30 '11 at 06:25
  • to make a Date object from a DatePicker you'd do new Date(datePicker.getYear() - 1900, datePicker.getMonth(), datePicker.getDayOfMonth()); – Sunil Kumar Sahoo Jun 30 '11 at 06:28
  • hey i got new one to convert our date& time into millis, epoch converter it is, so that we may pass converted form to put(). can u suggest to how can i use this? – Abhi Jun 30 '11 at 06:43