Abhi
Abhi

Reputation: 9005

adding event to calendar dynamically

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.

Upvotes: 0

Views: 2796

Answers (1)

Sunil Kumar Sahoo
Sunil Kumar Sahoo

Reputation: 53647

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);

Upvotes: 1

Related Questions